diff options
author | kaiwu <kaiwu2004@gmail.com> | 2022-12-08 12:30:20 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2022-12-08 12:30:20 +0800 |
commit | 33c75ac0c078bd50b560ea2f0361d8230585568f (patch) | |
tree | 1d41b4024a06705f45a79af0237139c63c8b5c45 /src | |
parent | 2aef63bbb79fc39031b23473f8949724b6af0f1e (diff) | |
download | advent-of-code-33c75ac0c078bd50b560ea2f0361d8230585568f.tar.gz advent-of-code-33c75ac0c078bd50b560ea2f0361d8230585568f.zip |
2015 day22 part1
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 { |