laneya2

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

commit
73729f0fdc150550aa84922ff3b81887202e81ee
parent
59a2fe93fbe3fabae8de359c395b7757e1f15672
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-10-05 09:24
refactor: adapt item wording

Diffstat

M player.go 42 +++++++++++++++++++++---------------------

1 files changed, 21 insertions, 21 deletions


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

@@ -82,38 +82,38 @@ func (player *Player) UnapplyItem(item Item) {
   82    82 	player.Speed -= item.Speed
   83    83 }
   84    84 
   85    -1 func (player *Player) AddItem(item string, amount uint) {
   86    -1 	value, ok := player.Inventory[item]
   -1    85 func (player *Player) AddItem(name string, added uint) {
   -1    86 	amount, ok := player.Inventory[name]
   87    87 	if ok {
   88    -1 		value += amount
   -1    88 		amount += added
   89    89 	} else {
   90    -1 		value = amount
   -1    90 		amount = added
   91    91 	}
   92    -1 	player.Inventory[item] = value
   -1    92 	player.Inventory[name] = amount
   93    93 
   94    94 	player.Enqueue(Message{
   95    95 		"action": "setInventory",
   96    -1 		"item":   item,
   97    -1 		"amount": value,
   -1    96 		"item":   name,
   -1    97 		"amount": amount,
   98    98 	})
   99    99 }
  100   100 
  101    -1 func (player *Player) RemoveItem(item string) {
  102    -1 	value, ok := player.Inventory[item]
   -1   101 func (player *Player) RemoveItem(name string) {
   -1   102 	amount, ok := player.Inventory[name]
  103   103 	if !ok {
  104    -1 		value = 0
  105    -1 	} else if value > 1 {
  106    -1 		value -= 1
  107    -1 		player.Inventory[item] = value
   -1   104 		amount = 0
   -1   105 	} else if amount > 1 {
   -1   106 		amount -= 1
   -1   107 		player.Inventory[name] = amount
  108   108 	} else {
  109    -1 		value = 0
  110    -1 		delete(player.Inventory, item)
   -1   109 		amount = 0
   -1   110 		delete(player.Inventory, name)
  111   111 	}
  112   112 
  113   113 	player.Enqueue(Message{
  114   114 		"action": "setInventory",
  115    -1 		"item":   item,
  116    -1 		"amount": value,
   -1   115 		"item":   name,
   -1   116 		"amount": amount,
  117   117 	})
  118   118 }
  119   119 
@@ -150,10 +150,10 @@ func (player *Player) PickupItems() {
  150   150 	}
  151   151 }
  152   152 
  153    -1 func (player *Player) DropItem(item string) {
  154    -1 	if _, ok := player.Inventory[item]; ok {
  155    -1 		player.RemoveItem(item)
  156    -1 		player.Game.addToPile(player.Pos, item, 1)
   -1   153 func (player *Player) DropItem(name string) {
   -1   154 	if _, ok := player.Inventory[name]; ok {
   -1   155 		player.RemoveItem(name)
   -1   156 		player.Game.addToPile(player.Pos, name, 1)
  157   157 	}
  158   158 }
  159   159