Skip to content

Commit

Permalink
Close #19
Browse files Browse the repository at this point in the history
Hopefully fix for #18
  • Loading branch information
MHIGists committed Sep 22, 2021
1 parent f777adf commit f88a5d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/TheClimbing/RPGLike/Commands/RPGCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
}
break;
case "upgrade":
RPGForms::upgradeStatsForm($sender, 0);
RPGForms::upgradeStatsForm($sender);
}
}
} else {
$sender->sendMessage($this->getPermissionMessage());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/TheClimbing/RPGLike/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function onLevelUp(PlayerExperienceChangeEvent $event)

$player->xplevel = $new_lvl;
$spleft = $new_lvl - $old_level;
$player->setSPleft($spleft);
$player->setSPleft($player->getSPleft() + $spleft);
$player->setHealth($player->getMaxHealth());
$player->setFood($player->getMaxFood());
$player->setAirSupplyTicks($player->getMaxAirSupplyTicks());
Expand Down
14 changes: 6 additions & 8 deletions src/TheClimbing/RPGLike/Forms/RPGForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ public function __construct(RPGLike $rpg)
self::$main = $rpg;
}

public static function upgradeStatsForm(RPGPlayer $player, int $spleft)
public static function upgradeStatsForm(RPGPlayer $player)
{
if ($player->getSPleft() > 0) {
$spleft += $player->getSPleft();
$player->setSPleft(0);
}
$spleft = $player->getSPleft();

if ($spleft <= 0) {
$player->setSPleft(0);
self::statsForm($player);
Expand Down Expand Up @@ -68,7 +66,7 @@ public static function upgradeStatsForm(RPGPlayer $player, int $spleft)
$player->setSPleft($spleft);
return;
}
self::upgradeStatsForm($player, $spleft);
self::upgradeStatsForm($player);

});

Expand Down Expand Up @@ -129,15 +127,15 @@ public static function menuForm(RPGPlayer $player)
self::statsForm($player, true);
break;
case "upgrade":
self::upgradeStatsForm($player, 0);
self::upgradeStatsForm($player);
break;
case "traits":
self::traitsForm($player);
}
});
$form->setTitle($menuStrings['title']);
foreach ($menuStrings['buttons'] as $key => $buttonText) {
if ($key == 'skills' && !$player->isSkillsUnlocked() || $key == 'traits' && !$player->isTraitsUnlocked()){
if (($key == 'skills' && !$player->isSkillsUnlocked()) || ($key == 'traits' && !$player->isTraitsUnlocked())){
continue;
}
$form->addButton($buttonText, -1, '', $key);
Expand Down

0 comments on commit f88a5d3

Please sign in to comment.