diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/2015/day22/aoc.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/2015/day22/aoc.cpp b/src/2015/day22/aoc.cpp index 2489124..bfc2a48 100644 --- a/src/2015/day22/aoc.cpp +++ b/src/2015/day22/aoc.cpp @@ -65,17 +65,19 @@ void start_of_each_turn (wizard& me, wizard& boss) { void instant_effect(spell* s, wizard& me, wizard& boss) { if (strcmp(s->name, "Magic Missile") == 0) { boss.points -= s->damage; + s->tick -= 1; } if (strcmp(s->name, "Drain") == 0) { boss.points -= s->damage; me.points += s->heals; + s->tick -= 1; } } void fight(int turn, wizard me, wizard boss, int cost, std::vector<int>& costs) { start_of_each_turn(me, boss); if (turn % 2 == 1) { // my turn - printf("player points[%d] armor[%d] mana[%d]\n", me.points, me.armor, me.mana); + // printf("player points[%d] armor[%d] mana[%d]\n", me.points, me.armor, me.mana); if (me.points > 0) { auto ss = can_spell(me); for(auto& s : ss) { @@ -88,13 +90,10 @@ void fight(int turn, wizard me, wizard boss, int cost, std::vector<int>& costs) s->tick = 0; } } - else { - printf("player lose\n"); - } } else { // boss turn printf("boss points[%d]\n", boss.points); if (boss.points <= 0) { // boss lose - printf("boss lose\n"); + printf("player win %d\n", cost); costs.push_back(cost); } else { |