Skip to content

Commit

Permalink
implemented #121
Browse files Browse the repository at this point in the history
  • Loading branch information
csacro committed May 4, 2020
1 parent 783431b commit a024c68
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/gameLogic/execution/ActionExecutor_Gamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@
// Created by jonas on 28.04.20.
//
#include "ActionExecutor.hpp"
#include "util/GameLogicUtils.hpp"

namespace spy::gameplay {
bool ActionExecutor::executeGamble(State &s, const GambleAction &op) {
auto character = s.getCharacters().getByUUID(op.getCharacterId());
character->subActionPoint();
// TODO: implement
return false;
auto targetField = s.getMap().getField(op.getTarget());

double winningChance = 18/37;
if (character->hasProperty(character::PropertyEnum::LUCKY_DEVIL)) {
winningChance = 32/37;
} else if (character->hasProperty(character::PropertyEnum::JINX)) {
winningChance = 13/37;
}
winningChance = targetField.isInverted() ? (1-winningChance) : winningChance;

bool won = util::GameLogicUtils::probabilityTestWithCharacter(s, *character, winningChance);
if (won) {
character->setChips(character->getChips() + op.getStake());
targetField.setChipAmount(targetField.getChipAmount().value() - op.getStake());
} else {
character->setChips(character->getChips() - op.getStake());
targetField.setChipAmount(targetField.getChipAmount().value() + op.getStake());
}

return won;
}
}

0 comments on commit a024c68

Please sign in to comment.