Skip to content

Commit

Permalink
Add 3 new flags for a player
Browse files Browse the repository at this point in the history
  • Loading branch information
Philaeux committed Aug 22, 2023
1 parent 07cc4e1 commit fce128f
Show file tree
Hide file tree
Showing 8 changed files with 760 additions and 29 deletions.
34 changes: 34 additions & 0 deletions src/dota_notes/alembic/versions/cf80d303e86f_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""empty message
Revision ID: cf80d303e86f
Revises: f240ff7795a9
Create Date: 2023-08-22 21:23:06.012752
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'cf80d303e86f'
down_revision: Union[str, None] = 'f240ff7795a9'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('players', sa.Column('rages_buyback', sa.Boolean(), nullable=False, server_default="0"))
op.add_column('players', sa.Column('bm_pause', sa.Boolean(), nullable=False, server_default="0"))
op.add_column('players', sa.Column('resumes_pause', sa.Boolean(), nullable=False, server_default="0"))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('players', 'resumes_pause')
op.drop_column('players', 'bm_pause')
op.drop_column('players', 'rages_buyback')
# ### end Alembic commands ###
31 changes: 16 additions & 15 deletions src/dota_notes/data/models/player_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class PlayerEntity(BaseEntity):
is_feeder: flag
gives_up: flag
destroys_items: flag
rages_buyback: flag
bm_pause: flag
resumes_pause: flag
note: user set note
"""
__tablename__ = 'players'
Expand All @@ -40,11 +43,14 @@ class PlayerEntity(BaseEntity):
is_feeder: Mapped[bool] = mapped_column()
gives_up: Mapped[bool] = mapped_column()
destroys_items: Mapped[bool] = mapped_column()
rages_buyback: Mapped[bool] = mapped_column()
bm_pause: Mapped[bool] = mapped_column()
resumes_pause: Mapped[bool] = mapped_column()
note: Mapped[str] = mapped_column(String(500))

def __init__(self, steam_id, name, pro_name=None, custom_name="", match_count=None, smurf="", smurf_stratz=None,
is_racist=False, is_sexist=False, is_toxic=False, is_feeder=False, gives_up=False,
destroys_items=False, note=""):
destroys_items=False, rages_buyback=False, bm_pause=False, resumes_pause=False, note=""):
self.steam_id = steam_id
self.name = name
self.pro_name = pro_name
Expand All @@ -58,6 +64,9 @@ def __init__(self, steam_id, name, pro_name=None, custom_name="", match_count=No
self.is_feeder = is_feeder
self.gives_up = gives_up
self.destroys_items = destroys_items
self.rages_buyback = rages_buyback
self.bm_pause = bm_pause
self.resumes_pause = resumes_pause
self.note = note

@staticmethod
Expand All @@ -67,20 +76,9 @@ def make_from_state(player_state):
Args:
player_state: state to import information from
"""
return PlayerEntity(
str(player_state.steam_id),
player_state.name,
player_state.pro_name if player_state.pro_name != "" else None,
player_state.custom_name,
player_state.match_count,
player_state.smurf,
player_state.smurf_stratz,
player_state.is_racist,
player_state.is_sexist,
player_state.is_toxic,
player_state.is_feeder,
player_state.gives_up,
player_state.destroys_items)
entity = PlayerEntity(str(player_state.steam_id), player_state.name)
PlayerEntity.import_export(from_object=player_state, to_object=entity)
return entity

@staticmethod
def import_export(from_object, to_object):
Expand All @@ -101,6 +99,9 @@ def import_export(from_object, to_object):
to_object.is_feeder = from_object.is_feeder
to_object.gives_up = from_object.gives_up
to_object.destroys_items = from_object.destroys_items
to_object.rages_buyback = from_object.rages_buyback
to_object.bm_pause = from_object.bm_pause
to_object.resumes_pause = from_object.resumes_pause
to_object.note = from_object.note

def __repr__(self) -> str:
Expand Down
4 changes: 3 additions & 1 deletion src/dota_notes/data/states/player_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class PlayerState(QObject):
gives_up = False
destroys_items = False
rages_buyback = False
bm_pause = False
resumes_pause = False
note = ""

ATTRIBUTES_FOR_COPY = ["steam_id", "avatar", "account_level", "medal", "country_code",
"pro_name", "custom_name", "match_count", "smurf", "smurf_stratz",
"is_racist", "is_sexist", "is_toxic", "is_feeder", "gives_up", "destroys_items",
"rages_buyback", "note"]
"rages_buyback", "bm_pause", "resumes_pause", "note"]

def copy_from(self, from_object):
"""Copy attributes from another object into this
Expand Down
2 changes: 2 additions & 0 deletions src/dota_notes/ui/app_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ def on_save_player_details(self):
player_state.gives_up = self.window.checkBoxDetailsGivesUp.isChecked()
player_state.destroys_items = self.window.checkBoxDetailsDestroysItems.isChecked()
player_state.rages_buyback = self.window.checkBoxDetailsBuyback.isChecked()
player_state.bm_pause = self.window.checkBoxDetailsPauseWar.isChecked()
player_state.resumes_pause = self.window.checkBoxDetailsResumesPause.isChecked()
player_state.note = self.window.inputDetailsNote.toPlainText()
self.window.draw_match_player(self.last_selected_index, player_state)
with Session(self.dota_notes.database.engine) as session:
Expand Down
Binary file added src/dota_notes/ui/images/resumes_pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/dota_notes/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
"""Application main window that is seeded with the generated class from .ui file"""

SMURF_CHOICES = ["", "Account Buyer", "Booster", "Main", "Maybe", "Smurf", "Sweaty Smurf"]
FLAGS = ["Racist", "Sexist", "Toxic", "Feeder", "GivesUp", "Destroyer", "Buyback"]
FLAGS = ["Racist", "Sexist", "Toxic", "Feeder", "GivesUp", "Destroyer", "Buyback", "BMPause", "ResumesPause"]
MODE_CHOICES = ["Client"]

def __init__(self):
Expand Down Expand Up @@ -100,6 +100,8 @@ def draw_match_player(self, player_slot, player_data):
getattr(self, f"labelPlayer{player_slot}FlagGivesUp").setVisible(player_data.gives_up)
getattr(self, f"labelPlayer{player_slot}FlagDestroyer").setVisible(player_data.destroys_items)
getattr(self, f"labelPlayer{player_slot}FlagBuyback").setVisible(player_data.rages_buyback)
getattr(self, f"labelPlayer{player_slot}FlagBMPause").setVisible(player_data.bm_pause)
getattr(self, f"labelPlayer{player_slot}FlagResumesPause").setVisible(player_data.resumes_pause)
getattr(self, f"labelPlayer{player_slot}Note").setVisible(len(player_data.note) > 0)

def draw_details_with_player(self, player_state):
Expand All @@ -124,4 +126,6 @@ def draw_details_with_player(self, player_state):
self.checkBoxDetailsGivesUp.setChecked(player_state.gives_up)
self.checkBoxDetailsDestroysItems.setChecked(player_state.destroys_items)
self.checkBoxDetailsBuyback.setChecked(player_state.rages_buyback)
self.checkBoxDetailsPauseWar.setChecked(player_state.bm_pause)
self.checkBoxDetailsResumesPause.setChecked(player_state.resumes_pause)
self.inputDetailsNote.setPlainText(player_state.note)
1 change: 1 addition & 0 deletions src/dota_notes/ui/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource>
<file>images/resumes_pause.png</file>
<file>images/evil_pause.png</file>
<file>images/rage_buyback.png</file>
<file>images/ranks/10.png</file>
Expand Down
Loading

0 comments on commit fce128f

Please sign in to comment.