Compare commits

..

No commits in common. "72275c491a1f48203f28f41800d9f5beff495306" and "9c328059fe1b3445e32d5d4d7301ff732db658b0" have entirely different histories.

3 changed files with 2 additions and 68 deletions

View File

@ -1,6 +1,4 @@
using System.Drawing; using System.Drawing;
using System.Reflection;
using MessagePack;
namespace PongGame.Hubs; namespace PongGame.Hubs;
@ -109,7 +107,7 @@ public struct PongGameState {
} }
public struct PongPaddleState { public struct PongPaddleState {
public const float PADDLE_LENGTH = HEIGHT / 6; public const float PADDLE_LENGTH = HEIGHT / 10;
public const float PADDLE_HALF_LENGTH = PADDLE_LENGTH / 2; public const float PADDLE_HALF_LENGTH = PADDLE_LENGTH / 2;
public const float PADDLE_WIDTH = PADDLE_LENGTH / 5; public const float PADDLE_WIDTH = PADDLE_LENGTH / 5;
public const float PADDLE_SPEED = 8; public const float PADDLE_SPEED = 8;
@ -123,17 +121,7 @@ public struct PongGameState {
public float Height; public float Height;
public PongPaddleDirection Direction; public PongPaddleDirection Direction;
[IgnoreMember] private int _score; public int Score;
public int Score {
get => _score; set {
if (_score != value) {
_score = value;
_ = Task.Run(() => ScoreChanged.Invoke(this, value));
}
}
}
public event EventHandler<int> ScoreChanged;
public static void Update(ref PongPaddleState state) public static void Update(ref PongPaddleState state)
=> state.Height = Math.Clamp(state.Height + ((int)state.Direction) * PADDLE_SPEED, PADDLE_HALF_LENGTH, HEIGHT - PADDLE_HALF_LENGTH); => state.Height = Math.Clamp(state.Height + ((int)state.Direction) * PADDLE_SPEED, PADDLE_HALF_LENGTH, HEIGHT - PADDLE_HALF_LENGTH);

View File

@ -1,53 +0,0 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from dataclasses import dataclass
from pathlib import Path
@dataclass
class Version:
major: int = 1
minor: int = 0
patch: int = 0
def __str__(self):
return f"{self.major}.{self.minor}.{self.patch}"
def __init__(self, version_str: str):
try:
match list(map(int, version_str.split("."))):
case [major, minor, patch]:
self.major, self.minor, self.patch = major, minor, patch
return
case _:
raise ValueError("Version file must contain 3 parts (SemVer)!")
except ValueError as e:
raise ValueError(f"Version must contain numbers only!") from e
def parse_args():
parser = ArgumentParser("build.py", description="Docker multi-arch build helper.")
version_group = parser.add_mutually_exclusive_group()
version_group.add_argument("--major", "-m", action="store_true", help="Increase the major version before building.")
version_group.add_argument("--minor", "-n", action="store_true", help="Increase the minor version before building.")
version_group.add_argument("--patch", "-p", action="store_true", help="Increase the patch version before building.")
parser.add_argument("--file", "-f", type=str, default="version.txt", help="File to store the current version in.")
return parser.parse_args()
def save_version(version_file: Path, version: Version):
with version_file.open("w", encoding="utf-8") as f:
f.write(str(version))
def load_version(version_file: Path):
try:
with version_file.open("r", encoding="utf-8") as f:
return Version(f.read().strip())
except FileNotFoundError:
return Version()
def main():
args = parse_args()
version_file = Path(args.file)
version = load_version(version_file)
save_version(version_file, version)
if __name__ == '__main__':
main()

View File

@ -1 +0,0 @@
1.0.0