|
@@ -7,6 +7,13 @@ class CurseScore:
|
|
|
score: int = 0
|
|
|
zero_passes: int = 0
|
|
|
|
|
|
+ def touch(self):
|
|
|
+ if self.score == 0:
|
|
|
+ self.zero_passes += 1
|
|
|
+
|
|
|
+ def __str__(self):
|
|
|
+ return f"{self.score}{'!' * self.zero_passes}"
|
|
|
+
|
|
|
|
|
|
class Target(Injector[str]):
|
|
|
async def inject(self, message: Message, context: Context) -> str:
|
|
@@ -21,33 +28,30 @@ class Target(Injector[str]):
|
|
|
|
|
|
@as_command
|
|
|
def karma(target: Target(), score: Data(CurseScore).For(Target())):
|
|
|
- return f"{target.capitalize()} = {score.score}{'!' * score.zero_passes}"
|
|
|
+ return f"{target.capitalize()} = {score}"
|
|
|
|
|
|
|
|
|
@as_command
|
|
|
async def curse(target: Target(), store: Data(CurseScore)):
|
|
|
score = await store.load_or(target)
|
|
|
score.score -= 1
|
|
|
- if score.score == 0:
|
|
|
- score.zero_passes += 1
|
|
|
+ score.touch()
|
|
|
await store.save(target, score)
|
|
|
- return f"{target.capitalize()} = {score.score}{'!' * score.zero_passes}"
|
|
|
+ return f"{target.capitalize()} = {score}"
|
|
|
|
|
|
|
|
|
@as_command
|
|
|
async def bless(target: Target(), store: Data(CurseScore)):
|
|
|
score = await store.load_or(target)
|
|
|
score.score += 1
|
|
|
- if score.score == 0:
|
|
|
- score.zero_passes += 1
|
|
|
+ score.touch()
|
|
|
await store.save(target, score)
|
|
|
- return f"{target.capitalize()} = {score.score}{'!' * score.zero_passes}"
|
|
|
+ return f"{target.capitalize()} = {score}"
|
|
|
|
|
|
|
|
|
@as_command
|
|
|
async def blurse(target: Target(), store: Data(CurseScore)):
|
|
|
score = await store.load_or(target)
|
|
|
- if score.score == 0:
|
|
|
- score.zero_passes += 1
|
|
|
+ score.touch()
|
|
|
await store.save(target, score)
|
|
|
- return f"{target.capitalize()} = {score.score}{'!' * score.zero_passes}"
|
|
|
+ return f"{target.capitalize()} = {score}"
|