laneya2

cave exploration game
git clone https://git.ce9e.org/laneya2.git

commit
52b433470da6a6bca848ef253ac286e55e5ed502
parent
73729f0fdc150550aa84922ff3b81887202e81ee
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-10-05 09:31
uneqip item on drop

Diffstat

M player.go 28 +++++++++++++++++++++-------

1 files changed, 21 insertions, 7 deletions


diff --git a/player.go b/player.go

@@ -48,11 +48,15 @@ func (player *Player) TakeDamage(attack float64) {
   48    48 		player.quit <- true
   49    49 	} else {
   50    50 		player.Health -= amount
   51    -1 		player.AnnounceStats()
   -1    51 		player.CommitStats()
   52    52 	}
   53    53 }
   54    54 
   55    -1 func (player *Player) AnnounceStats() {
   -1    55 func (player *Player) CommitStats() {
   -1    56 	if player.Health > player.HealthTotal {
   -1    57 		player.Health = player.HealthTotal
   -1    58 	}
   -1    59 
   56    60 	player.Enqueue(Message{
   57    61 		"action":      "setStats",
   58    62 		"health":      player.Health,
@@ -108,6 +112,20 @@ func (player *Player) RemoveItem(name string) {
  108   112 	} else {
  109   113 		amount = 0
  110   114 		delete(player.Inventory, name)
   -1   115 
   -1   116 		if name == player.Weapon {
   -1   117 			player.Weapon = ""
   -1   118 			if item, ok := Items[name]; ok {
   -1   119 				player.UnapplyItem(item)
   -1   120 				player.CommitStats()
   -1   121 			}
   -1   122 		} else if name == player.Armor {
   -1   123 			player.Armor = ""
   -1   124 			if item, ok := Items[name]; ok {
   -1   125 				player.UnapplyItem(item)
   -1   126 				player.CommitStats()
   -1   127 			}
   -1   128 		}
  111   129 	}
  112   130 
  113   131 	player.Enqueue(Message{
@@ -203,9 +221,5 @@ func (player *Player) UseItem(name string) {
  203   221 		}
  204   222 	}
  205   223 
  206    -1 	if player.Health > player.HealthTotal {
  207    -1 		player.Health = player.HealthTotal
  208    -1 	}
  209    -1 
  210    -1 	player.AnnounceStats()
   -1   224 	player.CommitStats()
  211   225 }