提问人:noobie coder 提问时间:11/17/2023 最后编辑:noobie coder 更新时间:11/17/2023 访问量:57
如何使充电和块状情况效果不叠加?[关闭]
How do I make the charge and block case effect not stack? [closed]
问:
我希望该方块仅在当前回合有效,而收费将应用于下一回合。这是我的职能。我只能使用条件、指针、循环、函数、开关大小写,我只能在切换情况下使用中断。除了我提到的之外,没有数组、结构、标志或其他概念允许我们使用。
void battleLogic(int playerMove, int enemyMove, int *playerHealth, int *enemyplayerHealth, int *playerAttack, int *playerDef, int *playerSPD,
int *enemyplayerAttack, int *enemyplayerDef, int *enemyplayerSPD) {
if (*playerSPD > *enemyplayerSPD || playerMove == 2) {
// Player goes first or both block (SPD values are ignored in the case of a block)
switch (playerMove) {
case 1: // Player chose Attack
if (enemyMove == 1) {
// Opponent chose Attack, player takes damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
} else if (enemyMove == 2) {
// Opponent chose Block, no damage to either player
} else if (enemyMove == 3) {
// Opponent chose Charge, no damage to player
}
break;
case 2: // Player chose Block
// Block action doubles player's DEF value for the current turn
*playerDef *= 2;
break;
case 3: // Player chose Charge
// Charge action doubles player's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
// Resolve enemy's move
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 2: // Enemy chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
} else if (*playerSPD < *enemyplayerSPD) {
// Opponent goes first
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 2: // Enemy chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
// Resolve player's move
switch (playerMove) {
case 1: // Player chose attack
if (enemyMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *playerAttack - *enemyplayerDef;
if (damage > 0) {
*enemyplayerHealth -= damage;
printf("You did %d damage.\n", damage);
} else {
printf("No damage dealt.\n");
}
}
break;
case 2: // Player chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Player chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
} else {
// Equal SPD values
if (playerMove == 2 && enemyMove == 2) {
// Both chose Block, no damage to either player
} else if (playerMove == 2) {
// Player chose Block, block action goes first
*playerDef *= 2;
} else if (enemyMove == 2) {
// Enemy chose Block, block action goes first
*enemyplayerDef *= 2;
} else {
// Both chose Attack or Charge, resolve simultaneously
// Resolve player's move
switch (playerMove) {
case 1: // Player chose attack
if (enemyMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *playerAttack - *enemyplayerDef;
if (damage > 0) {
*enemyplayerHealth -= damage;
printf("You did %d damage.\n", damage);
} else {
printf("No damage dealt.\n");
}
}
break;
case 3: // Player chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
// Resolve enemy's move
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
}
}
// Check for end of game
if (*playerHealth <= 0 && *enemyplayerHealth <= 0) {
printf("DRAW!\n");
} else if (*playerHealth <= 0) {
printf("Enemy Wins!\n");
} else if (*enemyplayerHealth <= 0) {
printf("You Win!\n");
}
}
这是我尝试过的
void battleLogic(int playerMove, int enemyMove, int *playerHealth, int *enemyplayerHealth, int *playerAttack, int *playerDef, int *playerSPD,
int *enemyplayerAttack, int *enemyplayerDef, int *enemyplayerSPD) {
if (*playerSPD > *enemyplayerSPD || playerMove == 2) {
// Player goes first or both block (SPD values are ignored in the case of a block)
switch (playerMove) {
case 1: // Player chose Attack
if (enemyMove == 1) {
// Opponent chose Attack, player takes damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
} else if (enemyMove == 2) {
// Opponent chose Block, no damage to either player
} else if (enemyMove == 3) {
// Opponent chose Charge, no damage to player
}
break;
case 2: // Player chose Block
// Block action doubles player's DEF value for the current turn
*playerDef *= 2;
break;
case 3: // Player chose Charge
// Charge action doubles player's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
// Resolve enemy's move
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 2: // Enemy chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
} else if (*playerSPD < *enemyplayerSPD) {
// Opponent goes first
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 2: // Enemy chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
// Resolve player's move
switch (playerMove) {
case 1: // Player chose attack
if (enemyMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *playerAttack - *enemyplayerDef;
if (damage > 0) {
*enemyplayerHealth -= damage;
printf("You did %d damage.\n", damage);
} else {
printf("No damage dealt.\n");
}
}
break;
case 2: // Player chose Block
// Block action doubles enemy's DEF value for the current turn
*enemyplayerDef *= 2;
break;
case 3: // Player chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
} else {
// Equal SPD values
if (playerMove == 2 && enemyMove == 2) {
// Both chose Block, no damage to either player
} else if (playerMove == 2) {
// Player chose Block, block action goes first
*playerDef *= 2;
} else if (enemyMove == 2) {
// Enemy chose Block, block action goes first
*enemyplayerDef *= 2;
} else {
// Both chose Attack or Charge, resolve simultaneously
// Resolve player's move
switch (playerMove) {
case 1: // Player chose attack
if (enemyMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *playerAttack - *enemyplayerDef;
if (damage > 0) {
*enemyplayerHealth -= damage;
printf("You did %d damage.\n", damage);
} else {
printf("No damage dealt.\n");
}
}
break;
case 3: // Player chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*playerAttack *= 2;
*playerSPD *= 2;
break;
default:
printf("Invalid move for player.\n");
}
// Resolve enemy's move
switch (enemyMove) {
case 1: // Enemy chose Attack
if (playerMove != 2) {
// If player did not choose Block, enemy deals damage
int damage = *enemyplayerAttack - *playerDef;
if (damage > 0) {
*playerHealth -= damage;
printf("Enemy did %d damage.\n", damage);
} else {
printf("Enemy dealt no damage.\n");
}
}
break;
case 3: // Enemy chose Charge
// Charge action doubles enemy's ATK and SPD values on the next turn
*enemyplayerAttack *= 2;
*enemyplayerSPD *= 2;
break;
default:
printf("Invalid move for enemy.\n");
}
}
}
*playerDef /= 2;
*playerAttack /= 2;
*playerSPD /= 2;
*enemyplayerDef /= 2;
*enemyplayerAttack /= 2;
*enemyplayerSPD /= 2;
// Check for end of game
if (*playerHealth <= 0 && *enemyplayerHealth <= 0) {
printf("DRAW!\n");
} else if (*playerHealth <= 0) {
printf("Enemy Wins!\n");
} else if (*enemyplayerHealth <= 0) {
printf("You Win!\n");
}
}
答: 暂无答案
评论