aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2022-12-08 19:47:56 +0800
committerkaiwu <kaiwu2004@gmail.com>2022-12-08 19:47:56 +0800
commita5c7c011332b064814239191a7379b26fd15618a (patch)
treed72c41bb0db8eb406ef3da4705a530744268f6c6 /src
parentead6f2df98f27d509b1365c6d34b52abb063e303 (diff)
downloadadvent-of-code-a5c7c011332b064814239191a7379b26fd15618a.tar.gz
advent-of-code-a5c7c011332b064814239191a7379b26fd15618a.zip
2015 day22 fix
Diffstat (limited to 'src')
-rw-r--r--src/2015/day22/aoc.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/2015/day22/aoc.cpp b/src/2015/day22/aoc.cpp
index e7d101c..c89ceac 100644
--- a/src/2015/day22/aoc.cpp
+++ b/src/2015/day22/aoc.cpp
@@ -35,11 +35,11 @@ char * indent(int t) {
}
void start_of_each_turn (int t, wizard& me, wizard& boss) {
- printf("%sT[%d] boss[%d] player[%d] armor[%d] mana[%d]\n", indent(t), t, boss.points, me.points, me.armor, me.mana);
- for (int i = 2; i < 5; i++) {
+ // printf("%sT[%d] boss[%d] player[%d] armor[%d] mana[%d]\n", indent(t), t, boss.points, me.points, me.armor, me.mana);
+ for (int i = 0; i < 5; i++) {
spell* s = boss.spells[i];
if (s->tick > 0) {
- printf("%sT[%d] %s has tick %d\n", indent(t), t, s->name, s->tick);
+ // printf("%sT[%d] %s has tick %d\n", indent(t), t, s->name, s->tick);
if (strcmp(s->name, "Shield") == 0) {
me.armor = 7;
}
@@ -62,24 +62,20 @@ void start_of_each_turn (int t, 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 restore_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;
}
}
@@ -101,7 +97,7 @@ void fight(int turn, wizard me, wizard boss, int cost, std::vector<int>& costs)
if (me.points > 0) {
auto ss = can_spell(me);
for(auto& s : ss) {
- printf("%sT[%d] choose %s =============\n", indent(turn), turn, s->name);
+ // printf("%sT[%d] choose %s =============\n", indent(turn), turn, s->name);
s->tick = s->turns;
me.mana -= s->costs;
instant_effect(s, me, boss);
@@ -118,7 +114,7 @@ void fight(int turn, wizard me, wizard boss, int cost, std::vector<int>& costs)
}
} else { // boss turn
if (boss.points <= 0) { // boss lose
- printf("%splayer win %d\n", indent(turn), cost);
+ // printf("%splayer win %d\n", indent(turn), cost);
costs.push_back(cost);
}
else {