mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-09-11 08:45:32 +03:00
Merge branch 'grid_game' of github.com:kind-lang/Kind into grid_game
This commit is contained in:
commit
62688aa39b
@ -85,7 +85,9 @@ App.GG.Creature.get(
|
||||
|
||||
|
||||
type App.GG.Creature.Status {
|
||||
flinch
|
||||
invulnerable(duration: U64)
|
||||
noname(duration: U64)
|
||||
poison(duration: U64, damage: I32)
|
||||
root(duration: U64)
|
||||
stun
|
||||
@ -107,7 +109,9 @@ App.GG.Creature.status_update_aux(
|
||||
[]
|
||||
cons:
|
||||
let head = case status.head {
|
||||
flinch: App.GG.Creature.Status.flinch
|
||||
invulnerable: App.GG.Creature.Status.invulnerable(status.head.duration - 1)
|
||||
noname: App.GG.Creature.Status.noname(status.head.duration -1)
|
||||
poison: App.GG.Creature.Status.poison(status.head.duration - 1, status.head.damage)
|
||||
root: App.GG.Creature.Status.root(status.head.duration - 1)
|
||||
stun: App.GG.Creature.Status.stun
|
||||
@ -115,7 +119,9 @@ App.GG.Creature.status_update_aux(
|
||||
}
|
||||
let tail = App.GG.Creature.status_update_aux(status.tail)
|
||||
case head {
|
||||
flinch: head & tail
|
||||
invulnerable: if U64.gtn(head.duration, 0) then head & tail else tail
|
||||
noname: head & tail
|
||||
poison: if U64.gtn(head.duration, 0) then head & tail else tail
|
||||
root: if U64.gtn(head.duration, 0) then head & tail else tail
|
||||
stun: head & tail
|
||||
@ -135,12 +141,22 @@ App.GG.Creature.add_status(
|
||||
}default creature
|
||||
else
|
||||
case status {
|
||||
flinch: App.GG.Creature.status_add_flinch(creature)
|
||||
invulnerable: App.GG.Creature.status_add_invulnerable(creature, status.duration)
|
||||
noname: App.GG.Creature.status_add_noname(creature, status.duration)
|
||||
poison: App.GG.Creature.status_add_poison(creature, status.duration, status.damage)
|
||||
root:App.GG.Creature.status_add_root(creature, status.duration)
|
||||
stun: App.GG.Creature.status_add_stun(creature)
|
||||
}
|
||||
|
||||
|
||||
App.GG.Creature.status_add_flinch(
|
||||
creature: App.GG.Creature
|
||||
): App.GG.Creature
|
||||
|
||||
let new_status = App.GG.Creature.Status.flinch & creature@status
|
||||
creature@status <- new_status
|
||||
|
||||
App.GG.Creature.status_add_invulnerable(
|
||||
creature: App.GG.Creature
|
||||
duration: U64
|
||||
@ -177,6 +193,42 @@ App.GG.Creature.status_check_invulnerable(
|
||||
}default false
|
||||
|
||||
|
||||
App.GG.Creature.status_add_noname(
|
||||
creature: App.GG.Creature
|
||||
duration: U64
|
||||
): App.GG.Creature
|
||||
|
||||
let new_status = App.GG.Creature.status_add_noname_aux(duration, creature@status)
|
||||
creature@status <- new_status
|
||||
|
||||
|
||||
App.GG.Creature.status_add_noname_aux(
|
||||
duration: U64
|
||||
status: List<App.GG.Creature.Status>
|
||||
): List<App.GG.Creature.Status>
|
||||
|
||||
let new_noname = App.GG.Creature.Status.noname(duration)
|
||||
case status {
|
||||
nil: new_noname & status
|
||||
cons:
|
||||
case status.head {
|
||||
noname:
|
||||
if U64.gtn(status.head.duration, duration) then
|
||||
status
|
||||
else
|
||||
new_noname & status.tail
|
||||
}default status.head & App.GG.Creature.status_add_noname_aux(duration, status.tail)
|
||||
}
|
||||
|
||||
App.GG.Creature.status_check_noname(
|
||||
creature: App.GG.Creature
|
||||
): Bool
|
||||
let status = creature@status
|
||||
case status {
|
||||
noname: true
|
||||
}default false
|
||||
|
||||
|
||||
App.GG.Creature.status_add_poison(
|
||||
creature: App.GG.Creature
|
||||
duration: U64
|
||||
@ -258,6 +310,8 @@ App.GG.Creature.del_status(status: App.GG.Creature.Status, creature: App.GG.Crea
|
||||
creature@status <- new_status
|
||||
|
||||
|
||||
//===========================================================
|
||||
|
||||
App.GG.Creature.sub_folder(quantity: Nat, creature: App.GG.Creature): App.GG.Creature
|
||||
case creature@category as monster {
|
||||
minion: creature
|
||||
|
@ -59,4 +59,7 @@ App.GG.Effect.creature.modify(mod: App.GG.Creature -> App.GG.Creature): App.GG.E
|
||||
App.GG.Effect.creature.modify_at(mod: App.GG.Creature -> App.GG.Creature, pos: App.GG.Coord): App.GG.Effect<Unit>
|
||||
(center, origin, grid)
|
||||
let new_grid = App.GG.Creature.modify_at(mod, pos, grid)
|
||||
App.GG.Effect.Result.new!(unit, center, origin, new_grid, (img) img, 0, "")
|
||||
App.GG.Effect.Result.new!(unit, center, origin, new_grid, (img) img, 0, "")
|
||||
|
||||
App.GG.Effect.creature.damage_at(dmg: I32, pos: App.GG.Coord, flinch: Bool): App.GG.Effect<I32>
|
||||
App.GG.Effect.creature.change_hp_at(I32.neg(dmg), pos, flinch)
|
||||
|
@ -73,5 +73,7 @@ App.GG.Effect.projectile.can_hit(coord: App.GG.Coord): App.GG.Effect<Bool>
|
||||
App.GG.Effect {
|
||||
get has_hit = App.GG.Effect.projectile.has_hit(coord) // Checks if projectile has already hit that enemy
|
||||
get is_enemy = App.GG.Effect.creature.is_enemy(coord) // Checks if projectile is over an enemy
|
||||
return not(has_hit) && is_enemy
|
||||
}
|
||||
get is_invulnerable = App.GG.Effect.status.is_invulnerable(coord) // Checks if projectile is trying to affect an invulnerable enemy
|
||||
get is_noname = App.GG.Effect.status.is_noname(coord) // Checks if projectile is trying to affect a creature with noname
|
||||
return not(is_noname) && not(is_invulnerable) && not(has_hit) && is_enemy
|
||||
}
|
||||
|
95
base/App/GG/Effect/status.kind
Normal file
95
base/App/GG/Effect/status.kind
Normal file
@ -0,0 +1,95 @@
|
||||
//TODO
|
||||
App.GG.Effect.status.is_invulnerable(pos: App.GG.Coord): App.GG.Effect<Bool>
|
||||
(center, origin, grid)
|
||||
let bool =
|
||||
Maybe {
|
||||
get creature = App.GG.Creature.get(pos, grid)
|
||||
return App.GG.Creature.status_check_invulnerable(creature)
|
||||
} <> false
|
||||
App.GG.Effect.Result.new!(bool, center, origin, grid, (img) img, 0, "")
|
||||
|
||||
|
||||
App.GG.Effect.status.is_noname(pos: App.GG.Coord): App.GG.Effect<Bool>
|
||||
(center, origin, grid)
|
||||
let bool =
|
||||
Maybe {
|
||||
get creature = App.GG.Creature.get(pos, grid)
|
||||
return App.GG.Creature.status_check_noname(creature)
|
||||
} <> false
|
||||
App.GG.Effect.Result.new!(bool, center, origin, grid, (img) img, 0, "")
|
||||
|
||||
|
||||
App.GG.Effect.status.add_noname(duration: U64): App.GG.Effect<Unit>
|
||||
App.GG.Effect {
|
||||
get frame = App.GG.Effect.frame.get
|
||||
get center = App.GG.Effect.coord.get_center
|
||||
let status = App.GG.Creature.Status.noname(duration)
|
||||
let mod = App.GG.Creature.modify_at(App.GG.Creature.add_status(status), center)
|
||||
App.GG.Effect.grid.modify(mod)
|
||||
}
|
||||
|
||||
|
||||
App.GG.Effect.status.noname(
|
||||
iframe: Bool
|
||||
): App.GG.Effect<Unit>
|
||||
|
||||
App.GG.Effect {
|
||||
let animation = App.GG.Animation.damage
|
||||
App.GG.Effect.stun(App.GG.Creature.Status.flinch, animation, 24)
|
||||
if iframe then
|
||||
App.GG.Effect.status.add_noname(1)
|
||||
else
|
||||
App.GG.Effect.pass
|
||||
}
|
||||
|
||||
App.GG.Effect.status.add_at(
|
||||
status: App.GG.Creature.Status
|
||||
pos: App.GG.Coord
|
||||
): App.GG.Effect<Unit>
|
||||
|
||||
App.GG.Effect {
|
||||
get grid = App.GG.Effect.grid.get
|
||||
let status_add = App.GG.Creature.add_status(status)
|
||||
let mod = App.GG.Creature.modify_at(status_add, pos)
|
||||
App.GG.Effect.grid.modify(mod)
|
||||
}
|
||||
|
||||
|
||||
App.GG.Effect.status.add_poison_at(
|
||||
damage: I32
|
||||
duration: U64
|
||||
pos: App.GG.Coord
|
||||
): App.GG.Effect<Unit>
|
||||
|
||||
App.GG.Effect {
|
||||
get creature = App.GG.Effect.creature.get_at(pos)
|
||||
without creature: App.GG.Effect.pass
|
||||
let poison = App.GG.Creature.Status.poison(duration, damage)
|
||||
App.GG.Effect.status.add_at(poison, pos)
|
||||
}
|
||||
|
||||
App.GG.Effect.status.poison_apply_at(
|
||||
damage: I32
|
||||
duration: U64
|
||||
pos: App.GG.Coord
|
||||
): App.GG.Effect<I32>
|
||||
|
||||
App.GG.Effect {
|
||||
if duration >? 0 then
|
||||
App.GG.Effect.creature.damage_at(damage, pos, false)
|
||||
else
|
||||
App.GG.Effect { return +0#32 }
|
||||
}
|
||||
|
||||
App.GG.Effect.status.apply_ot(
|
||||
creature: App.GG.Creature
|
||||
): App.GG.Effect<Unit>
|
||||
|
||||
App.GG.Effect {
|
||||
let status = creature@status
|
||||
case status {
|
||||
poison: App.GG.Effect.creature.damage_at(status.head.damage, status.head.duration, false)
|
||||
}default App.GG.Effect.pass
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user