Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
# Oyuncu sınıfı tanımı
|
5 |
class Player:
|
@@ -16,8 +17,52 @@ class Player:
|
|
16 |
self.penalty_points = 0
|
17 |
self.score = 0
|
18 |
|
19 |
-
#
|
20 |
-
players =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Oyuncu ekleme fonksiyonu
|
23 |
def add_player(name):
|
@@ -30,19 +75,22 @@ new_player_name = st.text_input("Oyuncu İsmi")
|
|
30 |
if st.button("Ekle"):
|
31 |
add_player(new_player_name)
|
32 |
st.success(f"{new_player_name} eklendi!")
|
|
|
33 |
|
34 |
# Oyuncu bilgilerini güncelleme arayüzü
|
35 |
st.header("Oyuncu Bilgilerini Güncelle")
|
36 |
for player in players:
|
37 |
st.subheader(player.name)
|
38 |
-
player.league_position = st.number_input(f"Lig Sıralaması ({player.name})", min_value=1, max_value=20)
|
39 |
-
player.target_hit = st.selectbox(f"Hedef Tutturması ({player.name})", options=[1, -1])
|
40 |
-
player.cup_stage = st.selectbox(f"Kupa Aşaması ({player.name})", options=[4, 3, 2, 1])
|
41 |
-
player.yellow_cards = st.number_input(f"Sarı Kartlar ({player.name})", min_value=0)
|
42 |
-
player.red_cards = st.number_input(f"Kırmızı Kartlar ({player.name})", min_value=0)
|
43 |
-
player.goals_conceded = st.number_input(f"Yenilen Goller ({player.name})", min_value=0)
|
44 |
-
player.goals_scored = st.number_input(f"Atılan Goller ({player.name})", min_value=0)
|
45 |
-
player.interviews = st.number_input(f"Röportaj Sayısı ({player.name})", min_value=0)
|
|
|
|
|
46 |
|
47 |
# Puan hesaplama fonksiyonları
|
48 |
def calculate_scores(players):
|
@@ -84,6 +132,7 @@ def calculate_fair_play_points(players):
|
|
84 |
if st.button("Puanları Hesapla"):
|
85 |
calculate_scores(players)
|
86 |
st.success("Puanlar hesaplandı!")
|
|
|
87 |
|
88 |
# Sonuçları görüntüleme
|
89 |
st.header("Sonuçlar")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import json
|
4 |
|
5 |
# Oyuncu sınıfı tanımı
|
6 |
class Player:
|
|
|
17 |
self.penalty_points = 0
|
18 |
self.score = 0
|
19 |
|
20 |
+
# Veri kaydetme fonksiyonu
|
21 |
+
def save_data(players, filename="players.json"):
|
22 |
+
data = []
|
23 |
+
for player in players:
|
24 |
+
player_data = {
|
25 |
+
"name": player.name,
|
26 |
+
"league_position": player.league_position,
|
27 |
+
"target_hit": player.target_hit,
|
28 |
+
"cup_stage": player.cup_stage,
|
29 |
+
"yellow_cards": player.yellow_cards,
|
30 |
+
"red_cards": player.red_cards,
|
31 |
+
"goals_conceded": player.goals_conceded,
|
32 |
+
"goals_scored": player.goals_scored,
|
33 |
+
"interviews": player.interviews,
|
34 |
+
"penalty_points": player.penalty_points,
|
35 |
+
"score": player.score
|
36 |
+
}
|
37 |
+
data.append(player_data)
|
38 |
+
with open(filename, "w") as f:
|
39 |
+
json.dump(data, f, indent=4)
|
40 |
+
|
41 |
+
# Veri yükleme fonksiyonu
|
42 |
+
def load_data(filename="players.json"):
|
43 |
+
with open(filename, "r") as f:
|
44 |
+
data = json.load(f)
|
45 |
+
players = []
|
46 |
+
for player_data in data:
|
47 |
+
player = Player(player_data["name"])
|
48 |
+
player.league_position = player_data["league_position"]
|
49 |
+
player.target_hit = player_data["target_hit"]
|
50 |
+
player.cup_stage = player_data["cup_stage"]
|
51 |
+
player.yellow_cards = player_data["yellow_cards"]
|
52 |
+
player.red_cards = player_data["red_cards"]
|
53 |
+
player.goals_conceded = player_data["goals_conceded"]
|
54 |
+
player.goals_scored = player_data["goals_scored"]
|
55 |
+
player.interviews = player_data["interviews"]
|
56 |
+
player.penalty_points = player_data["penalty_points"]
|
57 |
+
player.score = player_data["score"]
|
58 |
+
players.append(player)
|
59 |
+
return players
|
60 |
+
|
61 |
+
# Uygulama başlatıldığında verileri yükle
|
62 |
+
try:
|
63 |
+
players = load_data()
|
64 |
+
except FileNotFoundError:
|
65 |
+
players = []
|
66 |
|
67 |
# Oyuncu ekleme fonksiyonu
|
68 |
def add_player(name):
|
|
|
75 |
if st.button("Ekle"):
|
76 |
add_player(new_player_name)
|
77 |
st.success(f"{new_player_name} eklendi!")
|
78 |
+
save_data(players)
|
79 |
|
80 |
# Oyuncu bilgilerini güncelleme arayüzü
|
81 |
st.header("Oyuncu Bilgilerini Güncelle")
|
82 |
for player in players:
|
83 |
st.subheader(player.name)
|
84 |
+
player.league_position = st.number_input(f"Lig Sıralaması ({player.name})", min_value=1, max_value=20, value=player.league_position or 1)
|
85 |
+
player.target_hit = st.selectbox(f"Hedef Tutturması ({player.name})", options=[1, -1], index=0 if player.target_hit == 1 else 1)
|
86 |
+
player.cup_stage = st.selectbox(f"Kupa Aşaması ({player.name})", options=[4, 3, 2, 1], index=player.cup_stage or 0)
|
87 |
+
player.yellow_cards = st.number_input(f"Sarı Kartlar ({player.name})", min_value=0, value=player.yellow_cards)
|
88 |
+
player.red_cards = st.number_input(f"Kırmızı Kartlar ({player.name})", min_value=0, value=player.red_cards)
|
89 |
+
player.goals_conceded = st.number_input(f"Yenilen Goller ({player.name})", min_value=0, value=player.goals_conceded)
|
90 |
+
player.goals_scored = st.number_input(f"Atılan Goller ({player.name})", min_value=0, value=player.goals_scored)
|
91 |
+
player.interviews = st.number_input(f"Röportaj Sayısı ({player.name})", min_value=0, value=player.interviews)
|
92 |
+
if st.button(f"Güncelle {player.name}"):
|
93 |
+
save_data(players)
|
94 |
|
95 |
# Puan hesaplama fonksiyonları
|
96 |
def calculate_scores(players):
|
|
|
132 |
if st.button("Puanları Hesapla"):
|
133 |
calculate_scores(players)
|
134 |
st.success("Puanlar hesaplandı!")
|
135 |
+
save_data(players)
|
136 |
|
137 |
# Sonuçları görüntüleme
|
138 |
st.header("Sonuçlar")
|