Skip to content

Commit

Permalink
Added debug logging to s!claim
Browse files Browse the repository at this point in the history
  • Loading branch information
plaaosert committed Jul 27, 2021
1 parent ecdbdea commit d3cd711
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
16 changes: 16 additions & 0 deletions sooch/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,20 @@ async def claim(client: discord.Client,
result = discord.Embed()
# Embed here needs to be modular since we have a lot of claim info. Do later todo

debug_data = (
"hours",
"spare_mins",
"this_claim_mult",
"basic_income",
"trans_income",
"crit_success",
"items_gained",
"tax_loss",
"event_currency"
)

result.add_field(name="Result test", value="```\n" + "\n".join("{:20} {}".format(
d + ":", getattr(claim_result, d)
) for d in debug_data) + "\n```")

return result
1 change: 1 addition & 0 deletions sooch/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def migrate(self):
"""
CREATE TABLE IF NOT EXISTS `player` (
`discord_id` BIGINT PRIMARY KEY,
`name` VARCHAR(32),
`sooch_skin` VARCHAR(50),
`embed_color` INT,
`sooch` DOUBLE PRECISION NOT NULL DEFAULT 0,
Expand Down
6 changes: 3 additions & 3 deletions sooch/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Handles incoming messages and dispatches them to the appropriate handler.
"""
from dataclasses import dataclass, field
from typing import Callable, Optional, List, Dict, Coroutine
from typing import Callable, Optional, List, Dict, Coroutine, Any

import discord
from sooch.commands import base, misc, help
Expand All @@ -12,11 +12,11 @@
class Command:
"""Class representing a command that can be executed."""
handler: Callable[[discord.Client, discord.Message, List[str]],
Coroutine[Optional[discord.Embed]]]
Coroutine[Any, Any, Optional[discord.Embed]]]
name: str = "s!invalid"
description: str = "No description provided"
syntax: Optional[str] = None
aliases: List[str] = field(default_factory=List[str])
aliases: List[str] = field(default_factory=list)


valid_prefix = {
Expand Down
5 changes: 3 additions & 2 deletions sooch/services/claiming.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class ClaimResult:

def determine_times(player: sooch.player.Player):
# Get base difference (in seconds) from the last stored claim time. Multiply by time acceleration.
base_diff = time.time() - player.last_claim_time
diff = base_diff * player.time_mult
base_diff = time.time() - player.last_claim
# diff = base_diff * player.time_mult TODO add calculated stats like this
diff = base_diff

minutes = diff // 60
hours = minutes // 60
Expand Down
2 changes: 1 addition & 1 deletion sooch/services/players_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def add_player(self, player: "Player"):
("INSERT INTO `player`"
"(`name`, `discord_id`, `sooch_skin`, `embed_color`,"
"`sooch`, `tsooch`, `csooch`, `last_claim`)"
"VALUES(?, ?, ?, ?, ?, ?, ?)"),
"VALUES(?, ?, ?, ?, ?, ?, ?, ?)"),
(player.name, player.discord_id, player.sooch_skin, player.embed_color,
player.sooch, player.tsooch, player.csooch, player.last_claim)
)
Expand Down
3 changes: 2 additions & 1 deletion sooch/sooch_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ def main():
sooch_bot.start_sooching()


main()
if __name__ == "__main__":
main()

0 comments on commit d3cd711

Please sign in to comment.