Skip to content

Commit

Permalink
Create a basic UI
Browse files Browse the repository at this point in the history
Fixes #1

Co-authored-by: IRaymanI <IRaymanI@users.noreply.github.com>
  • Loading branch information
IaKee and IRaymanI committed Jan 14, 2023
1 parent f684e7f commit d563c3a
Show file tree
Hide file tree
Showing 44 changed files with 2,498,399 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": ["test", "v"]
}
]
}
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
# TFTechs
# TFTechs
```
TFTechs
├─ .git
│ ├─ config
│ ├─ description
│ ├─ FETCH_HEAD
│ ├─ HEAD
│ ├─ hooks
│ │ ├─ applypatch-msg.sample
│ │ ├─ commit-msg.sample
│ │ ├─ fsmonitor-watchman.sample
│ │ ├─ post-update.sample
│ │ ├─ pre-applypatch.sample
│ │ ├─ pre-commit.sample
│ │ ├─ pre-merge-commit.sample
│ │ ├─ pre-push.sample
│ │ ├─ pre-rebase.sample
│ │ ├─ pre-receive.sample
│ │ ├─ prepare-commit-msg.sample
│ │ ├─ push-to-checkout.sample
│ │ └─ update.sample
│ ├─ index
│ ├─ info
│ │ └─ exclude
│ ├─ logs
│ │ ├─ HEAD
│ │ └─ refs
│ │ ├─ heads
│ │ │ ├─ Gdamage
│ │ │ │ └─ issue1
│ │ │ └─ main
│ │ └─ remotes
│ │ └─ origin
│ │ └─ HEAD
│ ├─ objects
│ │ ├─ info
│ │ └─ pack
│ │ ├─ pack-14fd020872a60143564b6cfdc051d0148d301b15.idx
│ │ └─ pack-14fd020872a60143564b6cfdc051d0148d301b15.pack
│ ├─ packed-refs
│ └─ refs
│ ├─ heads
│ │ ├─ Gdamage
│ │ │ └─ issue1
│ │ └─ main
│ ├─ remotes
│ │ └─ origin
│ │ └─ HEAD
│ └─ tags
├─ .gitignore
├─ .vscode
│ └─ launch.json
├─ app.py
├─ assets
├─ controller.py
├─ LICENSE
├─ main.py
├─ model.py
├─ README.md
├─ requirements.txt
├─ updater
│ ├─ main.py
│ └─ ui
│ └─ updater.py
├─ view.py
└─ widgets
├─ CustomTk.py
└─ __init__.py
```
5 changes: 5 additions & 0 deletions TFTechs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
name = "TFTechs"
version = "0.0.1"
license = {file= "LICENSE"}
keywords = {"calculator", "helper", "league of legends", "lol", "probabilities", "statistics", "tactics", "teamfight", "tft"}
9 changes: 9 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from tkinter import Tk
from model import Model

class App(Tk):
def __init__(self, *args, **kwargs):
# initializes super
Tk.__init__(self, *args, **kwargs)

self.model = Model
229 changes: 229 additions & 0 deletions assets/Model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# changes hierachy level to import other modules
from sys import path
path.insert(1, '.')

# module imports
from json import load

# local imports
from utils import resource_path, string_starts_with

class AbilityVariable:
def __init__(
self,
name,
value):
self.name = name
self.value = value
class Ability:
def __init__(
self,
description,
icon,
name,
variables):
self.description = description
self.icon = icon
self.name = name
self.variables = variables
class ChampionStats:
def __init__(
self,
armor,
attack_speed,
crit_chance,
crit_multiplier,
attack_damage,
hp,
initial_mana,
magic_resist,
mana,
attack_range):
self.armor = armor
self.attack_speed = attack_speed
self.crit_chance = crit_chance
self.crit_multiplier = crit_multiplier
self.attack_damage = attack_damage
self.hp = hp
self.initial_mana = initial_mana
self.magic_resist = magic_resist
self.mana = mana
self.attack_range = attack_range
class Champion:
"""Champion attributes"""
def __init__(
self,
name,
champion_id,
cost,
ability,
icon,
traits,
stats):
self.name = name
self.champion_id = champion_id
self.cost = cost
self.ability = ability
self.icon = icon
self.traits = traits
self.stats = stats

def print_attributes(self):
print(f'id: {self.id}')
print(f'name {self.name}')
print(f'cost: {self.cost}')
class Trait:
def __init__(
self,
trait_id,
description,
icon,
name,
effects):
self.trait_id = trait_id
self.description = description
self.icon = icon
self.name = name
self.effects = effects
class TraitEffects:
def __init__(
self,
min_units,
max_units,
style,
variables):
self.min_units = min_units
self.max_units = max_units
self.style = style
self.variables = variables

class Model:
def __init__(self):
self.lang = 'en_US'
self.set_number = '8'
self.api_prefix = f'TFT{self.set_number}'

try:
lang_file_path = resource_path(f'lang/{self.lang}.json')

# opens selected language file
with open(lang_file_path, 'r') as lf:
lang_file = load(lf)

# items
self.items = lang_file['items']
for item in self.items:
item_prefix = f'{self.api_prefix}_Item'
augment_prefix = f'{self.api_prefix}_Augment'
admin_cause_prefix = f'{self.api_prefix}_AdminCause'
admin_effect_prefix = f'{self.api_prefix}_AdminEffect'
hyper_roll_augment_prefix = f'{self.api_prefix}_HyperRollAugment'
consumable_prefix = f'{self.api_prefix}_Consumable'
if(string_starts_with(item['apiName'], self.api_prefix)):
# set items
if(string_starts_with(item['apiName'], item_prefix)):
None
# augments
elif(string_starts_with(item['apiName'], augment_prefix)):
None
# admin cause
elif(string_starts_with(item['apiName'], admin_cause_prefix)):
None
# admin effect
elif(string_starts_with(item['apiName'], admin_effect_prefix)):
None
# hyper roll augments
elif(string_starts_with(item['apiName'], hyper_roll_augment_prefix)):
None
# consumables
elif(string_starts_with(item['apiName'], consumable_prefix)):
None
else:
print(item['apiName'])

# set data
self.set_data = lang_file['setData']

# sets
sets = lang_file['sets']
self.current_set = sets[self.set_number]
self.set_name = self.current_set['name']

# set champions
self.champion_list = []
for champion in self.current_set['champions']:
# checks for 'TFT{set_number} substring on the id
substring = f'TFT{self.set_number}'
champion_id = champion['apiName']

# if champion belongs to current set
if(string_starts_with(champion_id, substring)):
# ability variables
variable_list = []
for variable in champion['ability']['variables']:
variable_list.append(
AbilityVariable(
name = variable['name'],
value = variable['value']))

# ability attributes
champ_ability = Ability(
description = champion['ability']['desc'],
icon = champion['ability']['icon'],
name = champion['ability']['name'],
variables = variable_list)

# champion stats
champion_stats = ChampionStats(
armor = champion['stats']['armor'],
attack_speed = champion['stats']['attackSpeed'],
crit_chance = champion['stats']['critChance'],
crit_multiplier = champion['stats']['critMultiplier'],
attack_damage = champion['stats']['damage'],
hp = champion['stats']['hp'],
initial_mana = champion['stats']['initialMana'],
magic_resist = champion['stats']['magicResist'],
mana = champion['stats']['mana'],
attack_range = champion['stats']['range'])

# adds champion to champion list
self.champion_list.append(
Champion(
name = champion['name'],
champion_id = champion['apiName'],
cost = champion['cost'],
ability = champ_ability,
icon = champion['icon'],
traits = champion['traits'],
stats = champion_stats))

# set traits
self.trait_list = []
for trait in self.current_set['traits']:
# trait effects
effect_list = []
for effect in trait['effects']:
# effect variables
variable_list = []
for variable in effect['variables']:
value = effect['variables'][variable]
variable_list.append(AbilityVariable(
name = variable,
value = value))
effect_list.append(
TraitEffects(
min_units = effect['minUnits'],
max_units = effect['maxUnits'],
style = effect['style'],
variables = variable_list))
self.trait_list.append(Trait(
trait_id = trait['apiName'],
description = trait['desc'],
icon = trait['icon'],
name = trait['name'],
effects = effect_list))
except IOError:
print('erro ao abrir arquivo')

test = Model()
# eof
4 changes: 4 additions & 0 deletions controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Controller:
def __init__(self, model, view):
self.model = model
self.view = view
2 changes: 2 additions & 0 deletions definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) # This is your Project Root
Loading

0 comments on commit d563c3a

Please sign in to comment.