added extra energy cost for using chips from different classes

This commit is contained in:
Derenash 2021-12-01 08:43:38 -03:00
parent 3c158f82c4
commit 3a61088373
3 changed files with 54 additions and 9 deletions

View File

@ -29,7 +29,6 @@ App.GG: App<App.GG.State>
// - Create a panel steal Chip
// - Show chips in hand in setup phase
// - Show chips in hand in game phase
// - Add higher energy cost for using chips from different types
// - make poison do damage
// - create more control chips that apply statuses
// - update status each frame before everything happens
@ -50,6 +49,7 @@ App.GG: App<App.GG.State>
// - Create customizations for buttons
// - Add comments to everything
// DONE: Add higher energy cost for using chips from different types
// DONE: Create simple statuses (stun, invulnerable, root, poison)
// DONE: Make attributes from body impact on life, energy, *AND DAMAGE*
// DONE: Show energy in chips selection

View File

@ -11,4 +11,12 @@ App.GG.Class.to_hue(class: App.GG.Class): U32
destruction : 0#32 // Red
power : 38#32 // Yellow
control : 183#32 // Purple
}
}
App.GG.Class.eql(a: App.GG.Class, b: App.GG.Class): Bool
case a b {
strength strength: true
destruction destruction: true
power power: true
control control: true
}default false

View File

@ -229,7 +229,8 @@ App.GG.when.get_chip(
Maybe {
get item = table@slots[index]
get chip = item@chip
get new_energy = App.GG.when.get_new_energy(chip@energy, energy)
get energy_cost = App.GG.when.get_energy_cost(chip, phase)
let new_energy = phase.energy - energy_cost
let new_item = item@chip <- none
let new_table = table@slots[index] <- new_item
let new_hand = chip & hand
@ -240,11 +241,45 @@ App.GG.when.get_chip(
phase
}
App.GG.when.get_new_energy(chip: I32, table: I32): Maybe<I32>
if chip >? table then
none
else
some(table - chip)
App.GG.when.get_energy_cost(chip: App.GG.Chip, phase: App.GG.Phase): Maybe<I32>
case phase {
setup:
let energy_cost_extra = App.GG.when.get_energy_cost.extra(chip, phase.hand)
let energy_cost = chip@energy + energy_cost_extra
if energy_cost >? phase.energy then
none
else
some(energy_cost)
game: none
}
App.GG.when.get_energy_cost.extra(chip: App.GG.Chip, hand: App.GG.Chips): I32
let class_a = chip@class
let energy = 0 :: I32
let f =
(c: App.GG.Chip)
let class_b = c@class
App.GG.Class.eql(class_a, class_b)
let f2 =
(class: App.GG.Class, c: App.GG.Chip,)
if App.GG.Class.eql(class, class_a) then
false
else
App.GG.Class.eql(class, c@class)
let has_class = List.find!(f, hand)
case has_class {
none:
for class in [App.GG.Class.strength, App.GG.Class.destruction, App.GG.Class.power, App.GG.Class.control] with energy:
if Maybe.is_some!(List.find!(f2(class), hand)) then
energy + 10
else
energy
energy
some:
energy
}
// caso não tenha sua classe - verificar quantas outras tem,
App.GG.when.return_chip(local: App.GG.State.local): IO<Maybe<App.State.local<App.GG.State>>>
let new_phase = App.GG.when.return_chip.phase(local@phase)
@ -266,7 +301,9 @@ App.GG.when.return_chip.phase(
cons:
let chip = hand.head
let slots = App.GG.when.return_chip.go(chip, table@slots)
let new_energy = chip@energy + phase.energy
let energy_cost_extra = App.GG.when.get_energy_cost.extra(chip, hand.tail)
let energy_cost = chip@energy + energy_cost_extra
let new_energy = energy_cost + phase.energy
let new_table = table@slots <- slots
let new_hand = hand.tail
let new_phase = App.GG.Phase.setup(new_table, new_hand, new_energy)