-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
142 lines (132 loc) · 4.41 KB
/
main.lua
File metadata and controls
142 lines (132 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
local obsi = require("obsi2")
local vars = require("vars")
local game = require("game")
local render = require("render")
local util = require("util")
local monitor = peripheral.find("monitor")
if monitor then
monitor.setTextScale(1)
local monx, mony = monitor.getSize()
monitor.setTextScale(monx / 51)
end
-- Obsi run functions --
function obsi.load()
game.makeHandTypesCopy()
game.resetDeck()
game.createBaseDeck()
vars.baseDeck = game.createBaseDeck()
vars.currentDeck = game.shuffleDeck(vars.baseDeck)
game.dealHand(vars.currentDeck, vars.handSize)
---- test stuff (giving jokers)
-- for joker in util.all(game.specialCards.Jokers) do
-- if (joker.name == "odd todd" or joker.name == "smeared joker") then
-- util.add(vars.heldJokers, joker)
-- end
-- end
-- for joker in util.all(game.specialCards.Jokers) do
-- util.add(vars.heldJokers, joker)
-- end
for i = 1, 5 do
util.add(vars.heldJokers, game.findRandomUniqueShopOption("Jokers", vars.heldJokers))
end
end
function obsi.onKeyPress(key)
vars.debugPrint[2] = keys.getName(key)
if util.costatus(vars.animation) == 'dead' then
if key == keys.space then -- Space to change sorting mode
game.changeSortMode()
end
if key == keys.q then -- Q to quit
obsi.quit()
end
-- debug keys
if key == keys.e then -- E to dealhand
game.dealHand(vars.currentDeck, 1)
end
if key == keys.t then
local randomJoker = game.findRandomUniqueShopOption("Jokers", vars.heldJokers)
util.add(vars.heldJokers, randomJoker)
end
if key == keys.y then
local randomConsumable = game.findRandomUniqueShopOption("Tarots", vars.heldConsumables)
util.add(vars.heldConsumables, randomConsumable)
end
end
end
function obsi.onMousePress(x, y, button)
if button == 1 then
-- in game click checks
if vars.gameState == "blind" then
if util.costatus(vars.animation) == 'dead' then
game.discardBtnClicked() -- DISCARD BUTTON
game.playBtnClicked() -- PLAY BUTTON
if game.handCollDown() then
game.selectHand(game.handCollDown())
game.updateSelectedCards()
end
if game.jokerCollDown() then
game.selectJoker(game.jokerCollDown())
end
if game.mouseCollCheck(24, 17, 3, 2) then -- SORT BUTTON
game.changeSortMode()
return
end
if game.mouseCollCheck(48, 14, 3, 3) then -- DECKVIEW
vars.gameState = "blindDeckview"
return
end
end
end
if vars.gameState == "blindDeckview" then -- EXIT DECKVIEW
vars.gameState = "blind"
return
end
end
if button == 2 then
if (game.drawTooltips(x, y)) then
return
end
if vars.gameState == "blind" then
if util.costatus(vars.animation) == 'dead' then
game.deselectAllCards()
end
end
end
end
function obsi.onMouseRelease(x, y)
vars.tooltip[3] = ""
end
vars.animation = util.cocreate(print)
function obsi.update()
if util.costatus(vars.animation) ~= 'dead' then
util.coresume(vars.animation)
return
end
end
function obsi.draw()
obsi.graphics.flushAll()
render.renderbg()
if vars.gameState == "blind" then -- ingame UI rendering
game.drawHand()
render.renderScore()
render.renderPlayBtn()
render.renderSortBtn()
render.renderDiscardBtn()
render.renderMoney()
render.renderAnte()
render.renderJokers()
render.renderConsumables()
render.renderDeck()
end
if vars.gameState == "blindDeckview" then -- ingame deck view
render.renderAllCards("viewScreen")
end
if vars.gameState == "shop" then
end
game.drawSparkles()
render.renderTooltip()
-- obsi.graphics.write(tostring(vars.debugPrint[1]), 26, 1, colors.white, colors.black)
obsi.graphics.write(tostring(vars.selectedJoker), 26, 1, colors.white, colors.black)
-- obsi.graphics.write(tostring(vars.debugPrint[3]), 1, 19, colors.white, colors.black)
end
obsi.init()