Skip to content

Commit

Permalink
Use MetaDicts in more places.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Jan 10, 2024
1 parent aef3937 commit fd595dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
23 changes: 12 additions & 11 deletions simalq/save_load.hy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
json
pickle
zipfile [ZipFile ZIP-STORED ZIP-DEFLATED]
metadict [MetaDict]
simalq.game-state [G]
simalq.util [menu-letters saved-games-dir mixed-number])
(setv T True F False)
Expand Down Expand Up @@ -96,28 +97,28 @@
(list (.iterdir (/ saved-games-dir (or quest-name G.quest.name))))
(except [FileNotFoundError]
[]))
(dict
(MetaDict
:path path
:main (= path.stem "main")
:time (. path (stat) st-mtime)
#** (get-saved-game-meta path)))
:key (fn [d] #(
(not (get d "main"))
(get d "time")))))
(not d.main)
d.time))))

(setv display-lines [
" Date DL Turn HP Score HP f. Poison f."
#* (lfor
[i save] (enumerate saves)
(.format " ({}) {:4} {:%Y %b %d %H:%M} {:3d} {:6,} {:5,} {:7,} {:>6} {:>10}"
(get menu-letters i)
(if (get save "main") "main" "")
(datetime.fromtimestamp (get save "time"))
(get save "level_n")
(get save "turn_n")
(get save "player_hp")
(get save "score")
(mixed-number (f/ #* (get save "player_hp_factor")))
(mixed-number (f/ #* (get save "poison_factor")))))])
(if save.main "main" "")
(datetime.fromtimestamp save.time)
save.level-n
save.turn-n
save.player-hp
save.score
(mixed-number (f/ #* save.player-hp-factor))
(mixed-number (f/ #* save.poison-factor))))])

#(saves display-lines))
11 changes: 6 additions & 5 deletions simalq/tile/item.hy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
simalq.macros [unless defmeth]
simalq.tile [deftile])
(import
metadict [MetaDict]
simalq.strings
simalq.util [CommandError]
simalq.game-state [G]
Expand Down Expand Up @@ -180,17 +181,17 @@
:eat-messages #("You drink a jar of poison. It tastes pretty bad.")
:hook-player-shot (meth []
(doc #[f[Explodes in a size-{(get poison-burst "size")} burst of poison, which does {(get poison-burst "dmg_monster")} poison damage to monsters and {(get poison-burst "dmg_player")} to you.]f])
(doc #[f[Explodes in a size-{poison-burst.size} burst of poison, which does {poison-burst.dmg-monster} poison damage to monsters and {poison-burst.dmg-player} to you.]f])
(burst-damage @pos :damage-type DamageType.Poison
:amount (*
[(get poison-burst "dmg_monster")]
(+ 1 (get poison-burst "size")))
[poison-burst.dmg-monster]
(+ 1 poison-burst.size))
:color 'moss-green
:player-amount (get poison-burst "dmg_player"))
:player-amount poison-burst.dmg-player)
(@rm-from-map))
:flavor "I think you're not supposed to drink this.")
(setv poison-burst (dict
(setv poison-burst (MetaDict
:size 2
:dmg-player 20
:dmg-monster 3))
Expand Down

0 comments on commit fd595dd

Please sign in to comment.