summaryrefslogtreecommitdiff
path: root/templates/game.html
blob: 690e16d8213812ced17b46a16298c3a765617c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{% extends "base.html" %}

{% block content %}
    <div style="display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;">
        <a href="{{ url_for('index', season_id=game.season_id, tab='schedule') }}" 
           style="text-decoration: none; background: #ddd; color: #333; padding: 5px 15px; font-family: var(--sans-font); font-weight: bold; border: 1px solid #ccc;">
           &larr; Back to Schedule
        </a>
        <h2 style="margin: 0; flex: 1; border: none;">Game Details</h2>
    </div>

    {% if game %}
        <div style="display: flex; justify-content: center; gap: 4rem; align-items: center; margin: 2rem 0; background: var(--bg-primary); padding: 2rem; border: 2px solid var(--deco-border);">
            <div style="text-align: center;">
                <h3>Away</h3>
                {% set is_away_team = current_user.is_authenticated and current_user.id|string == game.away_team_id|string %}
                {% if game.away_icon %}
                    <img src="{{ url_for('static', filename='uploads/' + game.away_icon) }}" style="width:100px; height:100px; border-radius:50%; border: {{ '5px solid gold' if is_away_team else '2px solid var(--text-accent)' }};">
                {% else %}
                    <div style="width: 100px; height: 100px; border-radius: 50%; background-color: var(--deco-border); display: inline-block; border: {{ '5px solid gold' if is_away_team else 'none' }};"></div>
                {% endif %}
                <h4>{{ game.away_team if game.away_team else 'TBD' }}</h4>
                <div style="font-size: 3rem; font-weight: bold; color: var(--deco-highlight);">{{ game.away_score if game.status == 'Final' else '-' }}</div>
            </div>

            <div style="text-align: center;">
                <div style="color: var(--text-accent); font-size: 2rem; margin-bottom: 1rem;">VS</div>
                <div style="color: var(--text-primary);">Date: {{ game.scheduled_date }}</div>
                <div style="color: var(--deco-highlight); font-weight: bold; margin-top: 1rem; text-transform: uppercase;">
                    {{ game.status }}
                    {% if game.is_conditional %}<span class="conditional-game" title="Conditional Game">*</span>{% endif %}
                </div>
                
                {% if current_user.is_admin %}
                    <div style="margin-top: 1rem;">
                        <a href="{{ url_for('admin_edit_game', game_id=game.id) }}" style="background: var(--deco-border); color: var(--bg-primary); padding: 5px 10px; text-decoration: none;">&#9998; Edit Game</a>
                    </div>
                {% endif %}
            </div>

            <div style="text-align: center;">
                <h3>Home</h3>
                {% set is_home_team = current_user.is_authenticated and current_user.id|string == game.home_team_id|string %}
                {% if game.home_icon %}
                    <img src="{{ url_for('static', filename='uploads/' + game.home_icon) }}" style="width:100px; height:100px; border-radius:50%; border: {{ '5px solid gold' if is_home_team else '2px solid var(--text-accent)' }};">
                {% else %}
                    <div style="width: 100px; height: 100px; border-radius: 50%; background-color: var(--deco-border); display: inline-block; border: {{ '5px solid gold' if is_home_team else 'none' }};"></div>
                {% endif %}
                <h4>{{ game.home_team if game.home_team else 'TBD' }}</h4>
                <div style="font-size: 3rem; font-weight: bold; color: var(--deco-highlight);">{{ game.home_score if game.status == 'Final' else '-' }}</div>
            </div>
        </div>

        {% if game.status == 'Final' and game.box_score and (game.box_score.away|sum + game.box_score.home|sum) > 0 %}
            <div style="margin-top: 2rem; overflow-x: auto;">
                <h3>Box Score</h3>
                <table style="width: 100%; font-family: var(--sans-font); border: 2px solid #000;">
                    <tr style="background: #eee;">
                        <th>Team</th>
                        <th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>Extra</th>
                        <th style="background: #ddd;">R</th><th>H</th><th>E</th>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">{{ game.away_team }}</td>
                        {% for val in game.box_score.away %}
                            <td style="{{ 'background: #f9f9f9; font-weight: bold;' if loop.index > 10 else '' }}">{{ val }}</td>
                        {% endfor %}
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">{{ game.home_team }}</td>
                        {% for val in game.box_score.home %}
                            <td style="{{ 'background: #f9f9f9; font-weight: bold;' if loop.index > 10 else '' }}">{{ val }}</td>
                        {% endfor %}
                    </tr>
                </table>
            </div>
        {% endif %}

        {% if game.status != 'Final' and submissions %}
            <div style="margin-top: 2rem;">
                <h3>Active Proposals</h3>
                {% for s in submissions %}
                    {% set show_score = s.away_score is not none and (s.away_score != game.away_score or s.home_score != game.home_score) %}
                    {% set show_date = s.proposed_date and s.proposed_date != game.scheduled_date %}
                    
                    {% if show_score or show_date %}
                        <div style="background: #fff; border: 1px solid var(--deco-border); padding: 1rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: flex-start;">
                            <div>
                                <p style="margin: 0;"><strong>From:</strong> {{ s.team_name }} ({{ s.username }})</p>
                                {% if show_score %}
                                    <p style="margin: 0.5rem 0 0 0;"><strong>Score:</strong> {{ game.away_team }} {{ s.away_score }} - {{ game.home_team }} {{ s.home_score }}</p>
                                    {% if s.box_score %}
                                        <details style="margin-top: 0.5rem;">
                                            <summary style="cursor: pointer; font-size: 0.85rem; color: #555;">View Proposed Box Score</summary>
                                            <table style="width: 100%; font-size: 0.75rem; margin-top: 0.5rem; border: 1px solid #ddd;">
                                                <tr style="background: #f5f5f5;">
                                                    <th>Team</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>Ex</th><th>R</th><th>H</th><th>E</th>
                                                </tr>
                                                <tr><td>Away</td>{% for v in s.box_score.away %}<td>{{ v }}</td>{% endfor %}</tr>
                                                <tr><td>Home</td>{% for v in s.box_score.home %}<td>{{ v }}</td>{% endfor %}</tr>
                                            </table>
                                        </details>
                                    {% endif %}
                                {% endif %}
                                {% if show_date %}
                                    <p style="margin: 0.5rem 0 0 0;"><strong>Date Proposal:</strong> {{ s.proposed_date }}</p>
                                {% endif %}
                            </div>
                            <div style="display: flex; gap: 0.5rem;">
                                {% if current_user.id|string == s.submitted_by_id|string %}
                                    <form method="POST" action="{{ url_for('retract_submission', game_id=game.id) }}">
                                        <button type="submit" style="background-color: #cc0000; font-size: 0.8rem; padding: 5px 10px;">Retract</button>
                                    </form>
                                {% elif current_user.is_authenticated and (current_user.id|string == game.away_team_id|string or current_user.id|string == game.home_team_id|string) %}
                                    <form method="POST" action="{{ url_for('agree_submission', game_id=game.id, submission_id=s.id) }}">
                                        <button type="submit" style="background-color: #008800; font-size: 0.8rem; padding: 5px 10px;">Agree & Finalize</button>
                                    </form>
                                {% endif %}
                            </div>
                        </div>
                    {% endif %}
                {% endfor %}
            </div>
        {% endif %}

        {% if game.status != 'Final' and current_user.is_authenticated and (current_user.id|string == game.away_team_id|string or current_user.id|string == game.home_team_id|string) %}
            <div style="margin-top: 2rem; display: flex; flex-direction: column; gap: 2rem;">
                <!-- Score Submission Form (Full Width) -->
                <div style="background: var(--bg-primary); padding: 2rem; border: 1px solid var(--deco-border);">
                    <h3>Submit Game Results</h3>
                    <form method="POST" action="{{ url_for('submit_game', game_id=game.id) }}" style="max-width: 100%;">
                        <div style="display: flex; gap: 1rem; margin-bottom: 1rem; max-width: 400px;">
                            <div style="flex: 1;">
                                <label for="away_score" style="display: block; margin-bottom: 0.5rem;">{{ game.away_team }} Score:</label>
                                <input type="number" id="away_score" name="away_score" required style="width: 100%;">
                            </div>
                            <div style="flex: 1;">
                                <label for="home_score" style="display: block; margin-bottom: 0.5rem;">{{ game.home_team }} Score:</label>
                                <input type="number" id="home_score" name="home_score" required style="width: 100%;">
                            </div>
                        </div>
                        
                        <div style="margin-bottom: 1rem; overflow-x: auto;">
                            <label style="display: block; margin-bottom: 0.5rem;">Box Score (Optional):</label>
                            <table style="width: 100%; border: 1px solid var(--deco-border); background: #fff;">
                                <tr style="background: #eee;">
                                    <th>Team</th>
                                    <th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>Extra</th><th>R</th><th>H</th><th>E</th>
                                </tr>
                                <tr>
                                    <td style="font-weight: bold; font-size: 0.8rem;">{{ game.away_team if game.away_team else 'Away' }}</td>
                                    {% for col in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "extra", "runs", "hits", "errors"] %}
                                        <td><input type="number" name="away_inn_{{ col }}" value="0" style="width: 35px; padding: 2px; text-align: center;"></td>
                                    {% endfor %}
                                </tr>
                                <tr>
                                    <td style="font-weight: bold; font-size: 0.8rem;">{{ game.home_team if game.home_team else 'Home' }}</td>
                                    {% for col in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "extra", "runs", "hits", "errors"] %}
                                        <td><input type="number" name="home_inn_{{ col }}" value="0" style="width: 35px; padding: 2px; text-align: center;"></td>
                                    {% endfor %}
                                </tr>
                            </table>
                        </div>
                        
                        <button type="submit" style="width: 200px;">Submit Scores</button>
                    </form>
                </div>

                <!-- Date Change Form -->
                <div style="background: var(--bg-primary); padding: 2rem; border: 1px solid var(--deco-border); max-width: 400px;">
                    <h3>Propose Date Change</h3>
                    <form method="POST" action="{{ url_for('submit_game', game_id=game.id) }}" style="max-width: 100%;">
                        <div style="margin-bottom: 1rem;">
                            <label for="proposed_date" style="display: block; margin-bottom: 0.5rem;">New Date:</label>
                            <input type="text" id="proposed_date" name="proposed_date" placeholder="YYYY-MM-DD" style="width: 100%;">
                        </div>
                        <button type="submit" style="width: 100%; background-color: var(--deco-highlight); color: white;">Propose Date</button>
                    </form>
                </div>
            </div>
        {% endif %}
    {% else %}
        <p>Game not found.</p>
    {% endif %}
{% endblock %}