MAINT: Apply pre-commit

Remove byte-order-marker pre-commit check as there would be
many adjustments necessary
This commit is contained in:
Martin Thoma
2022-03-05 09:29:23 +01:00
parent f5e33ae38f
commit e64fb6795c
536 changed files with 6267 additions and 5556 deletions

View File

@@ -21,7 +21,7 @@ public abstract class AttackStrategy
{
Other.DamageTaken += 2;
}
Work.Push(punch.Punch switch
{
Punch.FullSwing => FullSwing,
@@ -36,7 +36,7 @@ public abstract class AttackStrategy
protected abstract void Hook();
protected abstract void Uppercut();
protected abstract void Jab();
protected void RegisterKnockout(string knockoutMessage)
{
Work.Clear();
@@ -45,4 +45,4 @@ public abstract class AttackStrategy
}
protected record AttackPunch(Punch Punch, bool IsBestPunch);
}
}

View File

@@ -42,4 +42,4 @@ public class Opponent : Boxer
Vulnerability = (Punch) GameUtils.Roll(4); // D1
} while (BestPunch == Vulnerability);
}
}
}

View File

@@ -112,4 +112,4 @@ public class OpponentAttackStrategy : AttackStrategy
private void RegisterOtherKnockedOut()
=> RegisterKnockout($"{Other} IS KNOCKED COLD AND {_opponent} IS THE WINNER AND CHAMP!");
}
}

View File

@@ -6,7 +6,7 @@ public class PlayerAttackStrategy : AttackStrategy
{
private readonly Boxer _player;
public PlayerAttackStrategy(Boxer player, Opponent opponent, Action notifyGameEnded, Stack<Action> work)
public PlayerAttackStrategy(Boxer player, Opponent opponent, Action notifyGameEnded, Stack<Action> work)
: base(opponent, work, notifyGameEnded) => _player = player;
protected override AttackPunch GetPunch()
@@ -118,4 +118,4 @@ public class PlayerAttackStrategy : AttackStrategy
void ScoreJabOnOpponent() => Other.DamageTaken += 3;
}
}
}

View File

@@ -6,9 +6,9 @@ WriteLine(new string('\t', 33) + "BOXING");
WriteLine(new string('\t', 15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
WriteLine("{0}{0}{0}BOXING OLYMPIC STYLE (3 ROUNDS -- 2 OUT OF 3 WINS){0}", Environment.NewLine);
var opponent = new Opponent();
var opponent = new Opponent();
opponent.SetName("WHAT IS YOUR OPPONENT'S NAME"); // J$
var player = new Boxer();
var player = new Boxer();
player.SetName("INPUT YOUR MAN'S NAME"); // L$
PrintPunchDescription();
@@ -26,4 +26,4 @@ for (var i = 1; i <= 3; i ++) // R
round.CheckPlayerWin();
if (round.GameEnded) break;
}
WriteLine("{0}{0}AND NOW GOODBYE FROM THE OLYMPIC ARENA.{0}", Environment.NewLine);
WriteLine("{0}{0}AND NOW GOODBYE FROM THE OLYMPIC ARENA.{0}", Environment.NewLine);

View File

@@ -6,4 +6,4 @@ public enum Punch
Hook = 2,
Uppercut = 3,
Jab = 4
}
}

View File

@@ -2,14 +2,14 @@
class Round
{
private readonly Boxer _player;
private readonly Boxer _opponent;
private readonly int _round;
private Stack<Action> _work = new();
private readonly PlayerAttackStrategy _playerAttackStrategy;
private readonly OpponentAttackStrategy _opponentAttackStrategy;
public bool GameEnded { get; private set; }
public Round(Boxer player, Opponent opponent, int round)
@@ -34,7 +34,7 @@ class Round
// This delay does not exist in the VB code but it makes a bit easier to follow the game.
// I assume the computers at the time were slow enough
// so that they did not need this delay...
Thread.Sleep(300);
Thread.Sleep(300);
action();
}
}
@@ -47,7 +47,7 @@ class Round
GameEnded = true;
}
}
public void CheckPlayerWin()
{
if (_player.IsWinner)
@@ -63,7 +63,7 @@ class Round
_opponent.ResetForNewRound();
_work.Push(RoundBegins);
}
private void RoundBegins()
{
Console.WriteLine();
@@ -93,4 +93,4 @@ class Round
{
_work.Push( GameUtils.RollSatisfies(10, x => x > 5) ? _opponentAttackStrategy.Attack : _playerAttackStrategy.Attack );
}
}
}

View File

@@ -17,7 +17,7 @@ public static class GameUtils
}
return result;
}
public static Func<int, int> Roll { get; } = upperLimit => (int) (upperLimit * Rnd.NextSingle()) + 1;
public static bool RollSatisfies(int upperLimit, Predicate<int> predicate) => predicate(Roll(upperLimit));
@@ -32,4 +32,4 @@ public static class GameUtils
_ => throw new ArgumentOutOfRangeException(nameof(punch), punch, null)
};
}
}