Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +104 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Oyuncu sınıfı tanımı
|
5 |
+
class Player:
|
6 |
+
def __init__(self, name):
|
7 |
+
self.name = name
|
8 |
+
self.league_position = None
|
9 |
+
self.target_hit = None
|
10 |
+
self.cup_stage = None
|
11 |
+
self.yellow_cards = 0
|
12 |
+
self.red_cards = 0
|
13 |
+
self.goals_conceded = 0
|
14 |
+
self.goals_scored = 0
|
15 |
+
self.interviews = 0
|
16 |
+
self.penalty_points = 0
|
17 |
+
self.score = 0
|
18 |
+
|
19 |
+
# Oyuncu listesi
|
20 |
+
players = []
|
21 |
+
|
22 |
+
# Oyuncu ekleme fonksiyonu
|
23 |
+
def add_player(name):
|
24 |
+
players.append(Player(name))
|
25 |
+
|
26 |
+
# Oyuncu ekleme arayüzü
|
27 |
+
st.title("Özel Online Score Manager Ligi")
|
28 |
+
st.header("Oyuncu Ekle")
|
29 |
+
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):
|
49 |
+
calculate_league_points(players)
|
50 |
+
calculate_target_points(players)
|
51 |
+
calculate_cup_points(players)
|
52 |
+
calculate_fair_play_points(players)
|
53 |
+
|
54 |
+
def calculate_league_points(players):
|
55 |
+
for player in players:
|
56 |
+
if player.league_position is not None:
|
57 |
+
player.score += (20 - player.league_position + 1)
|
58 |
+
|
59 |
+
def calculate_target_points(players):
|
60 |
+
for player in players:
|
61 |
+
if player.target_hit is not None:
|
62 |
+
player.score += player.target_hit
|
63 |
+
|
64 |
+
def calculate_cup_points(players):
|
65 |
+
for player in players:
|
66 |
+
if player.cup_stage is not None:
|
67 |
+
player.score += player.cup_stage
|
68 |
+
|
69 |
+
def calculate_fair_play_points(players):
|
70 |
+
min_yellow_cards = min(players, key=lambda p: p.yellow_cards).yellow_cards
|
71 |
+
min_red_cards = min(players, key=lambda p: p.red_cards).red_cards
|
72 |
+
min_goals_conceded = min(players, key=lambda p: p.goals_conceded).goals_conceded
|
73 |
+
max_interviews = max(players, key=lambda p: p.interviews).interviews
|
74 |
+
|
75 |
+
for player in players:
|
76 |
+
if player.yellow_cards == min_yellow_cards and player.red_cards == min_red_cards:
|
77 |
+
player.score += 1
|
78 |
+
if player.goals_conceded == min_goals_conceded:
|
79 |
+
player.score += 1
|
80 |
+
if player.interviews >= 25:
|
81 |
+
player.score += 1
|
82 |
+
|
83 |
+
# Puan hesaplama
|
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")
|
90 |
+
results = [{"Oyuncu": player.name, "Puan": player.score} for player in players]
|
91 |
+
results_df = pd.DataFrame(results)
|
92 |
+
st.table(results_df)
|
93 |
+
|
94 |
+
# Excel çıktısı
|
95 |
+
def to_excel(df):
|
96 |
+
output = io.BytesIO()
|
97 |
+
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
98 |
+
df.to_excel(writer, index=False, sheet_name='Sheet1')
|
99 |
+
writer.save()
|
100 |
+
processed_data = output.getvalue()
|
101 |
+
return processed_data
|
102 |
+
|
103 |
+
excel_data = to_excel(results_df)
|
104 |
+
st.download_button(label="Excel İndir", data=excel_data, file_name='sonuclar.xlsx', mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pandas
|
3 |
+
xlsxwriter
|