1.0.0 : Web Implemented.
This commit is contained in:
25
web/templates/tactics/analysis.html
Normal file
25
web/templates/tactics/analysis.html
Normal file
@@ -0,0 +1,25 @@
|
||||
{% extends "tactics/layout.html" %}
|
||||
|
||||
{% block title %}Deep Analysis - Tactics{% endblock %}
|
||||
|
||||
{% block tactics_content %}
|
||||
<div class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">Deep Analysis: Chemistry & Depth</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<!-- Lineup Selector (Placeholder) -->
|
||||
<div class="border-2 border-dashed border-gray-300 dark:border-slate-600 rounded-lg p-8 flex flex-col items-center justify-center text-center">
|
||||
<svg class="w-12 h-12 text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
|
||||
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Lineup Builder</h3>
|
||||
<p class="text-gray-500 dark:text-gray-400">Drag 5 players here to analyze chemistry.</p>
|
||||
</div>
|
||||
|
||||
<!-- Synergy Matrix (Placeholder) -->
|
||||
<div class="border-2 border-dashed border-gray-300 dark:border-slate-600 rounded-lg p-8 flex flex-col items-center justify-center text-center">
|
||||
<svg class="w-12 h-12 text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"></path></svg>
|
||||
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Synergy Matrix</h3>
|
||||
<p class="text-gray-500 dark:text-gray-400">Select lineup to view pair-wise win rates.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
396
web/templates/tactics/board.html
Normal file
396
web/templates/tactics/board.html
Normal file
@@ -0,0 +1,396 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Strategy Board - Tactics{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<!-- Leaflet CSS -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
|
||||
<style>
|
||||
.player-token {
|
||||
cursor: grab;
|
||||
transition: transform 0.1s;
|
||||
}
|
||||
.player-token:active {
|
||||
cursor: grabbing;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
#map-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #1a1a1a;
|
||||
z-index: 1;
|
||||
}
|
||||
.leaflet-container {
|
||||
background: #1a1a1a;
|
||||
}
|
||||
.custom-scroll::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.custom-scroll::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
.custom-scroll::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(156, 163, 175, 0.5);
|
||||
border-radius: 20px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex flex-col h-[calc(100vh-4rem)]">
|
||||
|
||||
<!-- Navigation (Compact) -->
|
||||
<div class="bg-white dark:bg-slate-800 border-b border-gray-200 dark:border-slate-700 px-4 py-2 flex items-center justify-between shrink-0 z-30 shadow-sm">
|
||||
<div class="flex space-x-6 text-sm font-medium">
|
||||
<a href="{{ url_for('tactics.index') }}" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">← Dashboard</a>
|
||||
<a href="{{ url_for('tactics.analysis') }}" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">Deep Analysis</a>
|
||||
<a href="{{ url_for('tactics.data') }}" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">Data Center</a>
|
||||
<span class="text-yrtv-600 dark:text-yrtv-400 border-b-2 border-yrtv-500">Strategy Board</span>
|
||||
<a href="{{ url_for('tactics.economy') }}" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">Economy</a>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">
|
||||
Real-time Sync: <span class="text-green-500">● Active</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Board Area -->
|
||||
<div class="flex flex-1 overflow-hidden" x-data="tacticsBoard()">
|
||||
|
||||
<!-- Left Sidebar: Controls & Roster -->
|
||||
<div class="w-72 flex flex-col bg-white dark:bg-slate-800 border-r border-gray-200 dark:border-slate-700 shadow-xl z-20">
|
||||
|
||||
<!-- Map Select -->
|
||||
<div class="p-4 border-b border-gray-200 dark:border-slate-700">
|
||||
<div class="flex space-x-2 mb-2">
|
||||
<select x-model="currentMap" @change="changeMap()" class="flex-1 rounded border-gray-300 dark:bg-slate-700 dark:border-slate-600 dark:text-white text-sm">
|
||||
<option value="de_mirage">Mirage</option>
|
||||
<option value="de_inferno">Inferno</option>
|
||||
<option value="de_dust2">Dust 2</option>
|
||||
<option value="de_nuke">Nuke</option>
|
||||
<option value="de_ancient">Ancient</option>
|
||||
<option value="de_anubis">Anubis</option>
|
||||
<option value="de_vertigo">Vertigo</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<button @click="saveBoard()" class="flex-1 px-3 py-1.5 bg-yrtv-600 text-white rounded hover:bg-yrtv-700 text-xs font-medium">Save Snapshot</button>
|
||||
<button @click="clearBoard()" class="px-3 py-1.5 bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 rounded hover:bg-red-200 dark:hover:bg-red-900/50 text-xs font-medium">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scrollable Content -->
|
||||
<div class="flex-1 overflow-y-auto custom-scroll p-4 space-y-6">
|
||||
|
||||
<!-- Roster (Draggable) -->
|
||||
<div>
|
||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3">Roster</h3>
|
||||
<div class="space-y-2">
|
||||
<template x-for="player in roster" :key="player.steam_id_64">
|
||||
<div class="player-token group flex items-center p-2 rounded-lg border border-transparent hover:bg-gray-50 dark:hover:bg-slate-700 hover:border-gray-200 dark:hover:border-slate-600 transition select-none cursor-grab active:cursor-grabbing"
|
||||
:data-id="player.steam_id_64"
|
||||
draggable="true"
|
||||
@dragstart="dragStart($event, player)">
|
||||
|
||||
<img :src="player.avatar_url || 'https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg'"
|
||||
class="w-8 h-8 rounded-full border border-gray-200 dark:border-slate-600 object-cover pointer-events-none">
|
||||
|
||||
<div class="ml-3 flex-1 min-w-0 pointer-events-none">
|
||||
<div class="text-xs font-medium text-gray-900 dark:text-white truncate" x-text="player.username || player.name"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template x-if="roster.length === 0">
|
||||
<div class="text-xs text-gray-500 text-center py-4 border-2 border-dashed border-gray-200 dark:border-slate-700 rounded-lg">
|
||||
No players found.
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Active Players List -->
|
||||
<div x-show="activePlayers.length > 0">
|
||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex justify-between items-center">
|
||||
<span>On Board</span>
|
||||
<span class="text-xs bg-yrtv-100 text-yrtv-800 dark:bg-yrtv-900 dark:text-yrtv-300 px-2 py-0.5 rounded-full" x-text="activePlayers.length"></span>
|
||||
</h3>
|
||||
<ul class="space-y-1">
|
||||
<template x-for="p in activePlayers" :key="p.id">
|
||||
<li class="flex items-center justify-between p-2 rounded bg-gray-50 dark:bg-slate-700/50">
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300 truncate" x-text="p.username || p.name"></span>
|
||||
<button @click="removeMarker(p.id)" class="text-gray-400 hover:text-red-500 transition">×</button>
|
||||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Radar Chart -->
|
||||
<div class="pt-4 border-t border-gray-200 dark:border-slate-700">
|
||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Synergy</h3>
|
||||
<div class="relative h-40 w-full">
|
||||
<canvas id="tacticRadar"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Map Area -->
|
||||
<div class="flex-1 relative bg-gray-900" id="map-dropzone" @dragover.prevent @drop="dropOnMap($event)">
|
||||
<div id="map-container"></div>
|
||||
|
||||
<div class="absolute bottom-4 right-4 z-[400] bg-black/50 backdrop-blur text-white text-[10px] px-2 py-1 rounded pointer-events-none">
|
||||
Drag players to map • Scroll to zoom
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
function tacticsBoard() {
|
||||
return {
|
||||
roster: [],
|
||||
currentMap: 'de_mirage',
|
||||
map: null,
|
||||
markers: {}, // id -> marker
|
||||
activePlayers: [], // list of {id, name, stats}
|
||||
radarChart: null,
|
||||
|
||||
init() {
|
||||
this.fetchRoster();
|
||||
this.initMap();
|
||||
this.initRadar();
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
if (this.map) this.map.invalidateSize();
|
||||
});
|
||||
},
|
||||
|
||||
fetchRoster() {
|
||||
fetch('/teams/api/roster')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
this.roster = data.roster || [];
|
||||
});
|
||||
},
|
||||
|
||||
initMap() {
|
||||
this.map = L.map('map-container', {
|
||||
crs: L.CRS.Simple,
|
||||
minZoom: -2,
|
||||
maxZoom: 2,
|
||||
zoomControl: true,
|
||||
attributionControl: false
|
||||
});
|
||||
|
||||
this.loadMapImage();
|
||||
},
|
||||
|
||||
loadMapImage() {
|
||||
const mapUrls = {
|
||||
'de_mirage': 'https://static.wikia.nocookie.net/cswikia/images/e/e3/Mirage_CS2_Radar.png',
|
||||
'de_inferno': 'https://static.wikia.nocookie.net/cswikia/images/7/77/Inferno_CS2_Radar.png',
|
||||
'de_dust2': 'https://static.wikia.nocookie.net/cswikia/images/0/03/Dust2_CS2_Radar.png',
|
||||
'de_nuke': 'https://static.wikia.nocookie.net/cswikia/images/1/14/Nuke_CS2_Radar.png',
|
||||
'de_ancient': 'https://static.wikia.nocookie.net/cswikia/images/1/16/Ancient_CS2_Radar.png',
|
||||
'de_anubis': 'https://static.wikia.nocookie.net/cswikia/images/2/22/Anubis_CS2_Radar.png',
|
||||
'de_vertigo': 'https://static.wikia.nocookie.net/cswikia/images/2/23/Vertigo_CS2_Radar.png'
|
||||
};
|
||||
|
||||
const url = mapUrls[this.currentMap] || mapUrls['de_mirage'];
|
||||
const bounds = [[0,0], [1024,1024]];
|
||||
|
||||
this.map.eachLayer((layer) => {
|
||||
this.map.removeLayer(layer);
|
||||
});
|
||||
|
||||
L.imageOverlay(url, bounds).addTo(this.map);
|
||||
this.map.fitBounds(bounds);
|
||||
},
|
||||
|
||||
changeMap() {
|
||||
this.loadMapImage();
|
||||
this.clearBoard();
|
||||
},
|
||||
|
||||
dragStart(event, player) {
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(player));
|
||||
event.dataTransfer.effectAllowed = 'copy';
|
||||
},
|
||||
|
||||
dropOnMap(event) {
|
||||
const data = event.dataTransfer.getData('text/plain');
|
||||
if (!data) return;
|
||||
|
||||
try {
|
||||
const player = JSON.parse(data);
|
||||
const container = document.getElementById('map-container');
|
||||
const rect = container.getBoundingClientRect();
|
||||
|
||||
const x = event.clientX - rect.left;
|
||||
const y = event.clientY - rect.top;
|
||||
|
||||
const point = this.map.containerPointToLatLng([x, y]);
|
||||
|
||||
this.addMarker(player, point);
|
||||
} catch (e) {
|
||||
console.error("Drop failed:", e);
|
||||
}
|
||||
},
|
||||
|
||||
addMarker(player, latlng) {
|
||||
if (this.markers[player.steam_id_64]) {
|
||||
this.markers[player.steam_id_64].setLatLng(latlng);
|
||||
} else {
|
||||
const displayName = player.username || player.name || player.steam_id_64;
|
||||
|
||||
const iconHtml = `
|
||||
<div class="flex flex-col items-center justify-center transform hover:scale-110 transition duration-200">
|
||||
<img src="${player.avatar_url || 'https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg'}"
|
||||
class="w-10 h-10 rounded-full border-2 border-white shadow-lg box-content">
|
||||
<span class="mt-1 text-[10px] font-bold text-white bg-black/60 px-1.5 py-0.5 rounded backdrop-blur-sm whitespace-nowrap overflow-hidden max-w-[80px] text-ellipsis">
|
||||
${displayName}
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const icon = L.divIcon({
|
||||
className: 'bg-transparent',
|
||||
html: iconHtml,
|
||||
iconSize: [60, 60],
|
||||
iconAnchor: [30, 30]
|
||||
});
|
||||
|
||||
const marker = L.marker(latlng, { icon: icon, draggable: true }).addTo(this.map);
|
||||
this.markers[player.steam_id_64] = marker;
|
||||
|
||||
this.activePlayers.push({
|
||||
id: player.steam_id_64,
|
||||
username: player.username,
|
||||
name: player.name,
|
||||
stats: player.stats
|
||||
});
|
||||
|
||||
this.updateRadar();
|
||||
}
|
||||
},
|
||||
|
||||
removeMarker(id) {
|
||||
if (this.markers[id]) {
|
||||
this.map.removeLayer(this.markers[id]);
|
||||
delete this.markers[id];
|
||||
this.activePlayers = this.activePlayers.filter(p => p.id !== id);
|
||||
this.updateRadar();
|
||||
}
|
||||
},
|
||||
|
||||
clearBoard() {
|
||||
for (let id in this.markers) {
|
||||
this.map.removeLayer(this.markers[id]);
|
||||
}
|
||||
this.markers = {};
|
||||
this.activePlayers = [];
|
||||
this.updateRadar();
|
||||
},
|
||||
|
||||
saveBoard() {
|
||||
const title = prompt("Enter a title for this strategy:", "New Strat " + new Date().toLocaleTimeString());
|
||||
if (!title) return;
|
||||
|
||||
const markerData = [];
|
||||
for (let id in this.markers) {
|
||||
const m = this.markers[id];
|
||||
markerData.push({
|
||||
id: id,
|
||||
lat: m.getLatLng().lat,
|
||||
lng: m.getLatLng().lng
|
||||
});
|
||||
}
|
||||
|
||||
fetch("{{ url_for('tactics.save_board') }}", {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
title: title,
|
||||
map_name: this.currentMap,
|
||||
markers: markerData
|
||||
})
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if(data.success) alert("Saved!");
|
||||
else alert("Error: " + data.message);
|
||||
});
|
||||
},
|
||||
|
||||
initRadar() {
|
||||
const ctx = document.getElementById('tacticRadar').getContext('2d');
|
||||
Chart.defaults.color = '#9ca3af';
|
||||
Chart.defaults.borderColor = '#374151';
|
||||
|
||||
this.radarChart = new Chart(ctx, {
|
||||
type: 'radar',
|
||||
data: {
|
||||
labels: ['RTG', 'K/D', 'KST', 'ADR', 'IMP', 'UTL'],
|
||||
datasets: [{
|
||||
label: 'Avg',
|
||||
data: [0, 0, 0, 0, 0, 0],
|
||||
backgroundColor: 'rgba(139, 92, 246, 0.2)',
|
||||
borderColor: 'rgba(139, 92, 246, 1)',
|
||||
pointBackgroundColor: 'rgba(139, 92, 246, 1)',
|
||||
borderWidth: 1,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
r: {
|
||||
beginAtZero: true,
|
||||
max: 1.5,
|
||||
grid: { color: 'rgba(156, 163, 175, 0.1)' },
|
||||
angleLines: { color: 'rgba(156, 163, 175, 0.1)' },
|
||||
pointLabels: { font: { size: 9 } },
|
||||
ticks: { display: false }
|
||||
}
|
||||
},
|
||||
plugins: { legend: { display: false } }
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateRadar() {
|
||||
if (this.activePlayers.length === 0) {
|
||||
this.radarChart.data.datasets[0].data = [0, 0, 0, 0, 0, 0];
|
||||
this.radarChart.update();
|
||||
return;
|
||||
}
|
||||
|
||||
let totals = [0, 0, 0, 0, 0, 0];
|
||||
this.activePlayers.forEach(p => {
|
||||
const s = p.stats || {};
|
||||
totals[0] += s.basic_avg_rating || 0;
|
||||
totals[1] += s.basic_avg_kd || 0;
|
||||
totals[2] += s.basic_avg_kast || 0;
|
||||
totals[3] += (s.basic_avg_adr || 0) / 100;
|
||||
totals[4] += s.bat_avg_impact || 1.0;
|
||||
totals[5] += s.util_usage_rate || 0.5;
|
||||
});
|
||||
|
||||
const count = this.activePlayers.length;
|
||||
const avgs = totals.map(t => t / count);
|
||||
|
||||
this.radarChart.data.datasets[0].data = avgs;
|
||||
this.radarChart.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
161
web/templates/tactics/compare.html
Normal file
161
web/templates/tactics/compare.html
Normal file
@@ -0,0 +1,161 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="space-y-6">
|
||||
<div class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">数据对比中心 (Data Center)</h2>
|
||||
|
||||
<!-- Search & Add -->
|
||||
<div class="mb-6 relative">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">添加对比玩家</label>
|
||||
<input type="text" id="playerSearch" placeholder="输入 ID 或昵称搜索..." class="w-full border border-gray-300 rounded-md py-2 px-4 dark:bg-slate-700 dark:text-white">
|
||||
<div id="searchResults" class="absolute z-10 w-full bg-white dark:bg-slate-700 shadow-lg rounded-b-md hidden"></div>
|
||||
</div>
|
||||
|
||||
<!-- Selected Players Tags -->
|
||||
<div id="selectedPlayers" class="flex flex-wrap gap-2 mb-6">
|
||||
<!-- Tags will be injected here -->
|
||||
</div>
|
||||
|
||||
<!-- Chart -->
|
||||
<div class="relative h-96">
|
||||
<canvas id="compareChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('playerSearch');
|
||||
const resultsDiv = document.getElementById('searchResults');
|
||||
const selectedDiv = document.getElementById('selectedPlayers');
|
||||
|
||||
let selectedIds = [];
|
||||
let chartInstance = null;
|
||||
|
||||
// Init Chart
|
||||
const ctx = document.getElementById('compareChart').getContext('2d');
|
||||
chartInstance = new Chart(ctx, {
|
||||
type: 'radar',
|
||||
data: {
|
||||
labels: ['STA', 'BAT', 'HPS', 'PTL', 'SIDE', 'UTIL'],
|
||||
datasets: []
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
r: {
|
||||
beginAtZero: true,
|
||||
suggestedMax: 2.0
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Search
|
||||
let debounceTimer;
|
||||
searchInput.addEventListener('input', function() {
|
||||
clearTimeout(debounceTimer);
|
||||
const query = this.value;
|
||||
if (query.length < 2) {
|
||||
resultsDiv.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
debounceTimer = setTimeout(() => {
|
||||
fetch(`/players/api/search?q=${query}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
resultsDiv.innerHTML = '';
|
||||
if (data.length > 0) {
|
||||
resultsDiv.classList.remove('hidden');
|
||||
data.forEach(p => {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'p-2 hover:bg-gray-100 dark:hover:bg-slate-600 cursor-pointer text-gray-900 dark:text-white';
|
||||
div.innerText = `${p.username} (${p.steam_id})`;
|
||||
div.onclick = () => addPlayer(p);
|
||||
resultsDiv.appendChild(div);
|
||||
});
|
||||
} else {
|
||||
resultsDiv.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// Hide results on click outside
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!searchInput.contains(e.target) && !resultsDiv.contains(e.target)) {
|
||||
resultsDiv.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
function addPlayer(player) {
|
||||
if (selectedIds.includes(player.steam_id)) return;
|
||||
selectedIds.push(player.steam_id);
|
||||
|
||||
// Add Tag
|
||||
const tag = document.createElement('span');
|
||||
tag.className = 'inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-yrtv-100 text-yrtv-800';
|
||||
tag.innerHTML = `
|
||||
${player.username}
|
||||
<button type="button" class="flex-shrink-0 ml-1.5 h-4 w-4 rounded-full inline-flex items-center justify-center text-yrtv-400 hover:bg-yrtv-200 hover:text-yrtv-500 focus:outline-none" onclick="removePlayer('${player.steam_id}', this)">
|
||||
<span class="sr-only">Remove</span>
|
||||
×
|
||||
</button>
|
||||
`;
|
||||
selectedDiv.appendChild(tag);
|
||||
|
||||
// Fetch Stats and Update Chart
|
||||
updateChart();
|
||||
|
||||
searchInput.value = '';
|
||||
resultsDiv.classList.add('hidden');
|
||||
}
|
||||
|
||||
window.removePlayer = function(id, btn) {
|
||||
selectedIds = selectedIds.filter(sid => sid !== id);
|
||||
btn.parentElement.remove();
|
||||
updateChart();
|
||||
}
|
||||
|
||||
function updateChart() {
|
||||
if (selectedIds.length === 0) {
|
||||
chartInstance.data.datasets = [];
|
||||
chartInstance.update();
|
||||
return;
|
||||
}
|
||||
|
||||
const ids = selectedIds.join(',');
|
||||
fetch(`/players/api/batch_stats?ids=${ids}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const datasets = data.map((p, index) => {
|
||||
const colors = [
|
||||
'rgba(124, 58, 237, 1)', 'rgba(16, 185, 129, 1)', 'rgba(239, 68, 68, 1)',
|
||||
'rgba(59, 130, 246, 1)', 'rgba(245, 158, 11, 1)'
|
||||
];
|
||||
const color = colors[index % colors.length];
|
||||
|
||||
return {
|
||||
label: p.username,
|
||||
data: [
|
||||
p.radar.STA, p.radar.BAT, p.radar.HPS,
|
||||
p.radar.PTL, p.radar.SIDE, p.radar.UTIL
|
||||
],
|
||||
backgroundColor: color.replace('1)', '0.2)'),
|
||||
borderColor: color,
|
||||
pointBackgroundColor: color
|
||||
};
|
||||
});
|
||||
|
||||
chartInstance.data.datasets = datasets;
|
||||
chartInstance.update();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
22
web/templates/tactics/data.html
Normal file
22
web/templates/tactics/data.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends "tactics/layout.html" %}
|
||||
|
||||
{% block title %}Data Center - Tactics{% endblock %}
|
||||
|
||||
{% block tactics_content %}
|
||||
<div class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">Data Center: Comparison</h2>
|
||||
|
||||
<div class="space-y-6">
|
||||
<!-- Controls -->
|
||||
<div class="flex space-x-4">
|
||||
<input type="text" placeholder="Search players to compare..." class="flex-1 rounded-md border-gray-300 dark:bg-slate-700 dark:border-slate-600 dark:text-white">
|
||||
<button class="px-4 py-2 bg-yrtv-600 text-white rounded-md">Add to Compare</button>
|
||||
</div>
|
||||
|
||||
<!-- Chart Placeholder -->
|
||||
<div class="h-96 bg-gray-50 dark:bg-slate-700 rounded flex items-center justify-center">
|
||||
<p class="text-gray-500 dark:text-gray-400">Multi-player Radar Chart / Bar Chart Area</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
65
web/templates/tactics/economy.html
Normal file
65
web/templates/tactics/economy.html
Normal file
@@ -0,0 +1,65 @@
|
||||
{% extends "tactics/layout.html" %}
|
||||
|
||||
{% block title %}Economy Calculator - Tactics{% endblock %}
|
||||
|
||||
{% block tactics_content %}
|
||||
<div class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">Economy Calculator</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<!-- Input Form -->
|
||||
<div class="space-y-4">
|
||||
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Current Round State</h3>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">Round Result</label>
|
||||
<select class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
<option>Won (Elimination/Time)</option>
|
||||
<option>Won (Bomb Defused)</option>
|
||||
<option>Lost (Elimination)</option>
|
||||
<option>Lost (Bomb Planted)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">Surviving Players</label>
|
||||
<input type="number" min="0" max="5" value="0" class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">Current Loss Bonus</label>
|
||||
<select class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
<option>$1400 (0)</option>
|
||||
<option>$1900 (1)</option>
|
||||
<option>$2400 (2)</option>
|
||||
<option>$2900 (3)</option>
|
||||
<option>$3400 (4+)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button class="w-full px-4 py-2 bg-yrtv-600 text-white rounded-md">Calculate Next Round</button>
|
||||
</div>
|
||||
|
||||
<!-- Output -->
|
||||
<div class="bg-gray-50 dark:bg-slate-700 p-6 rounded-lg">
|
||||
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">Prediction</h3>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-300">Team Money (Min)</span>
|
||||
<span class="font-bold text-gray-900 dark:text-white">$12,400</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-300">Team Money (Max)</span>
|
||||
<span class="font-bold text-gray-900 dark:text-white">$18,500</span>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 dark:border-slate-600 pt-4">
|
||||
<span class="block text-sm text-gray-500 dark:text-gray-400">Recommendation</span>
|
||||
<span class="block text-xl font-bold text-green-600 dark:text-green-400">Full Buy</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
471
web/templates/tactics/index.html
Normal file
471
web/templates/tactics/index.html
Normal file
@@ -0,0 +1,471 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Tactics Center{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<!-- Leaflet CSS -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
|
||||
<style>
|
||||
.player-token { cursor: grab; transition: transform 0.1s; }
|
||||
.player-token:active { cursor: grabbing; transform: scale(1.05); }
|
||||
#map-container { background-color: #1a1a1a; z-index: 1; }
|
||||
.leaflet-container { background: #1a1a1a; }
|
||||
.custom-scroll::-webkit-scrollbar { width: 6px; }
|
||||
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
|
||||
.custom-scroll::-webkit-scrollbar-thumb { background-color: rgba(156, 163, 175, 0.5); border-radius: 20px; }
|
||||
[x-cloak] { display: none !important; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex h-[calc(100vh-4rem)] overflow-hidden" x-data="tacticsApp()" x-cloak>
|
||||
|
||||
<!-- Left Sidebar: Roster (Permanent) -->
|
||||
<div class="w-72 flex flex-col bg-white dark:bg-slate-800 border-r border-gray-200 dark:border-slate-700 shadow-xl z-20 shrink-0">
|
||||
<div class="p-4 border-b border-gray-200 dark:border-slate-700">
|
||||
<h2 class="text-lg font-bold text-gray-900 dark:text-white">队员列表 (Roster)</h2>
|
||||
<p class="text-xs text-gray-500">拖拽队员至右侧功能区</p>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto custom-scroll p-4 space-y-2">
|
||||
<template x-for="player in roster" :key="player.steam_id_64">
|
||||
<div class="player-token group flex items-center p-2 rounded-lg border border-transparent hover:bg-gray-50 dark:hover:bg-slate-700 hover:border-gray-200 dark:hover:border-slate-600 transition select-none cursor-grab active:cursor-grabbing"
|
||||
:data-id="player.steam_id_64"
|
||||
draggable="true"
|
||||
@dragstart="dragStart($event, player)">
|
||||
|
||||
<img :src="player.avatar_url || 'https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg'"
|
||||
class="w-10 h-10 rounded-full border border-gray-200 dark:border-slate-600 object-cover pointer-events-none">
|
||||
|
||||
<div class="ml-3 flex-1 min-w-0 pointer-events-none">
|
||||
<div class="text-sm font-medium text-gray-900 dark:text-white truncate" x-text="player.username || player.name || player.steam_id_64"></div>
|
||||
<!-- Tag Display -->
|
||||
<div class="flex flex-wrap gap-1 mt-0.5">
|
||||
<template x-for="tag in player.tags">
|
||||
<span class="text-[10px] bg-gray-100 dark:bg-slate-600 text-gray-600 dark:text-gray-300 px-1 rounded" x-text="tag"></span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template x-if="roster.length === 0">
|
||||
<div class="text-sm text-gray-500 text-center py-8">
|
||||
暂无队员,请去 <a href="/teams" class="text-yrtv-600 hover:underline">Team</a> 页面添加。
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right Content Area -->
|
||||
<div class="flex-1 flex flex-col min-w-0 bg-gray-50 dark:bg-gray-900">
|
||||
|
||||
<!-- Top Navigation Tabs -->
|
||||
<div class="bg-white dark:bg-slate-800 border-b border-gray-200 dark:border-slate-700 px-4">
|
||||
<nav class="-mb-px flex space-x-8">
|
||||
<button @click="switchTab('analysis')" :class="{'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400': activeTab === 'analysis', 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400': activeTab !== 'analysis'}" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition">
|
||||
深度分析 (Deep Analysis)
|
||||
</button>
|
||||
<button @click="switchTab('data')" :class="{'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400': activeTab === 'data', 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400': activeTab !== 'data'}" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition">
|
||||
数据中心 (Data Center)
|
||||
</button>
|
||||
<button @click="switchTab('board')" :class="{'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400': activeTab === 'board', 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400': activeTab !== 'board'}" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition">
|
||||
战术白板 (Strategy Board)
|
||||
</button>
|
||||
<button @click="switchTab('economy')" :class="{'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400': activeTab === 'economy', 'border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400': activeTab !== 'economy'}" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition">
|
||||
经济计算 (Economy)
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- Tab Contents -->
|
||||
<div class="flex-1 overflow-y-auto p-6 relative">
|
||||
|
||||
<!-- 1. Deep Analysis -->
|
||||
<div x-show="activeTab === 'analysis'" class="space-y-6">
|
||||
<h3 class="text-xl font-bold text-gray-900 dark:text-white">阵容化学反应分析</h3>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Drop Zone -->
|
||||
<div class="bg-white dark:bg-slate-800 p-6 rounded-lg shadow min-h-[300px]"
|
||||
@dragover.prevent @drop="dropAnalysis($event)">
|
||||
<h4 class="font-medium text-gray-700 dark:text-gray-300 mb-4 flex justify-between">
|
||||
<span x-text="'阵容构建 (' + analysisLineup.length + '/5)'">阵容构建 (0/5)</span>
|
||||
<button @click="clearAnalysis()" class="text-xs text-red-500 hover:underline">清空</button>
|
||||
</h4>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-5 gap-4">
|
||||
<template x-for="(p, idx) in analysisLineup" :key="p.steam_id_64">
|
||||
<div class="relative bg-gray-50 dark:bg-slate-700 p-2 rounded border border-gray-200 dark:border-slate-600 flex flex-col items-center">
|
||||
<button @click="removeFromAnalysis(idx)" class="absolute top-1 right-1 text-red-400 hover:text-red-600">×</button>
|
||||
<img :src="p.avatar_url" class="w-12 h-12 rounded-full mb-2">
|
||||
<span class="text-xs font-bold truncate w-full text-center dark:text-white" x-text="p.username || p.name"></span>
|
||||
<span class="text-[10px] text-gray-500" x-text="'R: ' + (p.stats?.basic_avg_rating || 0).toFixed(2)"></span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Empty Slots -->
|
||||
<template x-for="i in (5 - analysisLineup.length)">
|
||||
<div class="border-2 border-dashed border-gray-300 dark:border-slate-600 rounded flex items-center justify-center h-24 text-gray-400 text-xs">
|
||||
拖拽至此
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
<button @click="analyzeLineup()" :disabled="analysisLineup.length < 1" class="w-full py-2 bg-yrtv-600 text-white rounded hover:bg-yrtv-700 disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
开始分析 (Analyze)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Results Area -->
|
||||
<div class="bg-white dark:bg-slate-800 p-6 rounded-lg shadow">
|
||||
<template x-if="!analysisResult">
|
||||
<div class="h-full flex items-center justify-center text-gray-400 text-sm">
|
||||
请先选择阵容并点击分析
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="analysisResult">
|
||||
<div class="space-y-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<h4 class="font-bold text-gray-900 dark:text-white">综合评分</h4>
|
||||
<span class="text-2xl font-bold text-yrtv-600" x-text="analysisResult.avg_stats.rating.toFixed(2)"></span>
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-2 text-center text-sm">
|
||||
<div class="bg-gray-50 dark:bg-slate-700 p-2 rounded">
|
||||
<div class="text-gray-500">Avg K/D</div>
|
||||
<div class="font-bold dark:text-white" x-text="analysisResult.avg_stats.kd.toFixed(2)"></div>
|
||||
</div>
|
||||
<div class="bg-gray-50 dark:bg-slate-700 p-2 rounded">
|
||||
<div class="text-gray-500">Avg ADR</div>
|
||||
<div class="font-bold dark:text-white" x-text="analysisResult.avg_stats.adr.toFixed(1)"></div>
|
||||
</div>
|
||||
<div class="bg-gray-50 dark:bg-slate-700 p-2 rounded">
|
||||
<div class="text-gray-500">共同场次</div>
|
||||
<div class="font-bold dark:text-white" x-text="analysisResult.shared_matches.length"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h5 class="text-sm font-bold text-gray-700 dark:text-gray-300 mb-2">近期共同比赛 (Recent Shared Matches)</h5>
|
||||
<div class="max-h-40 overflow-y-auto text-xs">
|
||||
<table class="min-w-full divide-y divide-gray-200 dark:divide-slate-600">
|
||||
<thead class="bg-gray-50 dark:bg-slate-700">
|
||||
<tr>
|
||||
<th class="px-2 py-1 text-left">Map</th>
|
||||
<th class="px-2 py-1 text-right">Score</th>
|
||||
<th class="px-2 py-1 text-right">Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 dark:divide-slate-700">
|
||||
<template x-for="m in analysisResult.shared_matches" :key="m.match_id">
|
||||
<tr>
|
||||
<td class="px-2 py-1 dark:text-gray-300" x-text="m.map_name"></td>
|
||||
<td class="px-2 py-1 text-right dark:text-gray-300" x-text="m.score_team1 + ':' + m.score_team2"></td>
|
||||
<td class="px-2 py-1 text-right font-bold" :class="m.winner_team ? 'text-green-600' : 'text-gray-500'" x-text="m.winner_team ? 'Win' : 'Draw/Loss'"></td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
<template x-if="analysisResult.shared_matches.length === 0">
|
||||
<p class="text-center text-gray-400 py-2">无共同比赛记录</p>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. Data Center (Placeholder) -->
|
||||
<div x-show="activeTab === 'data'" class="flex items-center justify-center h-full">
|
||||
<div class="text-center">
|
||||
<div class="text-4xl mb-4">📊</div>
|
||||
<h3 class="text-xl font-bold text-gray-900 dark:text-white">数据对比中心 (Construction)</h3>
|
||||
<p class="text-gray-500">此模块正在开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. Strategy Board -->
|
||||
<div x-show="activeTab === 'board'" class="h-full flex flex-col">
|
||||
<!-- Map Controls -->
|
||||
<div class="mb-4 flex justify-between items-center bg-white dark:bg-slate-800 p-3 rounded shadow">
|
||||
<div class="flex space-x-2">
|
||||
<select x-model="currentMap" @change="changeMap()" class="rounded border-gray-300 dark:bg-slate-700 dark:border-slate-600 dark:text-white text-sm">
|
||||
<option value="de_mirage">Mirage</option>
|
||||
<option value="de_inferno">Inferno</option>
|
||||
<option value="de_dust2">Dust 2</option>
|
||||
<option value="de_nuke">Nuke</option>
|
||||
<option value="de_ancient">Ancient</option>
|
||||
<option value="de_anubis">Anubis</option>
|
||||
<option value="de_vertigo">Vertigo</option>
|
||||
</select>
|
||||
<button @click="clearBoard()" class="px-3 py-1 bg-red-100 text-red-700 rounded hover:bg-red-200 text-sm">清空 (Clear)</button>
|
||||
<button @click="saveBoard()" class="px-3 py-1 bg-green-100 text-green-700 rounded hover:bg-green-200 text-sm">保存快照 (Save)</button>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
在场人数: <span x-text="boardPlayers.length" class="font-bold text-yrtv-600"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Map Area -->
|
||||
<div class="flex-1 relative bg-gray-900 rounded-lg overflow-hidden border border-gray-700"
|
||||
id="board-dropzone"
|
||||
@dragover.prevent
|
||||
@drop="dropBoard($event)">
|
||||
<div id="map-container" class="w-full h-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 4. Economy -->
|
||||
<div x-show="activeTab === 'economy'" class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">经济计算器 (Economy Calculator)</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">本回合结果</label>
|
||||
<select x-model="econ.result" class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
<option value="win">胜利 (Won)</option>
|
||||
<option value="loss">失败 (Lost)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">连败加成等级 (Loss Bonus)</label>
|
||||
<select x-model="econ.lossBonus" class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
<option value="0">$1400 (0)</option>
|
||||
<option value="1">$1900 (1)</option>
|
||||
<option value="2">$2400 (2)</option>
|
||||
<option value="3">$2900 (3)</option>
|
||||
<option value="4">$3400 (4+)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">存活人数</label>
|
||||
<input type="number" x-model="econ.surviving" min="0" max="5" class="mt-1 block w-full rounded-md border-gray-300 dark:bg-slate-700 dark:text-white">
|
||||
</div>
|
||||
|
||||
<div class="pt-4">
|
||||
<div class="p-4 bg-gray-100 dark:bg-slate-700 rounded-lg">
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">下回合收入预测</div>
|
||||
<div class="text-3xl font-bold text-green-600 dark:text-green-400" x-text="'$' + calculateIncome()"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- External Libs -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
function tacticsApp() {
|
||||
return {
|
||||
activeTab: 'analysis',
|
||||
roster: [],
|
||||
|
||||
// Analysis State
|
||||
analysisLineup: [],
|
||||
analysisResult: null,
|
||||
|
||||
// Board State
|
||||
currentMap: 'de_mirage',
|
||||
map: null,
|
||||
markers: {},
|
||||
boardPlayers: [],
|
||||
|
||||
// Economy State
|
||||
econ: {
|
||||
result: 'loss',
|
||||
lossBonus: '0',
|
||||
surviving: 0
|
||||
},
|
||||
|
||||
init() {
|
||||
this.fetchRoster();
|
||||
// Init map on first board view, or delay
|
||||
this.$watch('activeTab', value => {
|
||||
if (value === 'board') {
|
||||
this.$nextTick(() => {
|
||||
if (!this.map) this.initMap();
|
||||
else this.map.invalidateSize();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fetchRoster() {
|
||||
fetch('/teams/api/roster')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
this.roster = data.roster || [];
|
||||
});
|
||||
},
|
||||
|
||||
switchTab(tab) {
|
||||
this.activeTab = tab;
|
||||
},
|
||||
|
||||
// --- Drag & Drop Generic ---
|
||||
dragStart(event, player) {
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(player));
|
||||
event.dataTransfer.effectAllowed = 'copy';
|
||||
},
|
||||
|
||||
// --- Analysis Logic ---
|
||||
dropAnalysis(event) {
|
||||
const data = event.dataTransfer.getData('text/plain');
|
||||
if (!data) return;
|
||||
const player = JSON.parse(data);
|
||||
|
||||
// Check duplicates
|
||||
if (this.analysisLineup.some(p => p.steam_id_64 === player.steam_id_64)) return;
|
||||
|
||||
// Limit 5
|
||||
if (this.analysisLineup.length >= 5) return;
|
||||
|
||||
this.analysisLineup.push(player);
|
||||
},
|
||||
|
||||
removeFromAnalysis(index) {
|
||||
this.analysisLineup.splice(index, 1);
|
||||
},
|
||||
|
||||
clearAnalysis() {
|
||||
this.analysisLineup = [];
|
||||
this.analysisResult = null;
|
||||
},
|
||||
|
||||
analyzeLineup() {
|
||||
const ids = this.analysisLineup.map(p => p.steam_id_64);
|
||||
fetch('/tactics/api/analyze', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({steam_ids: ids})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
this.analysisResult = data;
|
||||
});
|
||||
},
|
||||
|
||||
// --- Board Logic ---
|
||||
initMap() {
|
||||
this.map = L.map('map-container', {
|
||||
crs: L.CRS.Simple,
|
||||
minZoom: -2,
|
||||
maxZoom: 2,
|
||||
zoomControl: true,
|
||||
attributionControl: false
|
||||
});
|
||||
this.loadMapImage();
|
||||
},
|
||||
|
||||
loadMapImage() {
|
||||
const mapUrls = {
|
||||
'de_mirage': 'https://static.wikia.nocookie.net/cswikia/images/e/e3/Mirage_CS2_Radar.png',
|
||||
'de_inferno': 'https://static.wikia.nocookie.net/cswikia/images/7/77/Inferno_CS2_Radar.png',
|
||||
'de_dust2': 'https://static.wikia.nocookie.net/cswikia/images/0/03/Dust2_CS2_Radar.png',
|
||||
'de_nuke': 'https://static.wikia.nocookie.net/cswikia/images/1/14/Nuke_CS2_Radar.png',
|
||||
'de_ancient': 'https://static.wikia.nocookie.net/cswikia/images/1/16/Ancient_CS2_Radar.png',
|
||||
'de_anubis': 'https://static.wikia.nocookie.net/cswikia/images/2/22/Anubis_CS2_Radar.png',
|
||||
'de_vertigo': 'https://static.wikia.nocookie.net/cswikia/images/2/23/Vertigo_CS2_Radar.png'
|
||||
};
|
||||
const url = mapUrls[this.currentMap] || mapUrls['de_mirage'];
|
||||
const bounds = [[0,0], [1024,1024]];
|
||||
|
||||
this.map.eachLayer((layer) => { this.map.removeLayer(layer); });
|
||||
L.imageOverlay(url, bounds).addTo(this.map);
|
||||
this.map.fitBounds(bounds);
|
||||
},
|
||||
|
||||
changeMap() {
|
||||
this.loadMapImage();
|
||||
this.clearBoard();
|
||||
},
|
||||
|
||||
dropBoard(event) {
|
||||
const data = event.dataTransfer.getData('text/plain');
|
||||
if (!data) return;
|
||||
const player = JSON.parse(data);
|
||||
|
||||
const container = document.getElementById('map-container');
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = event.clientX - rect.left;
|
||||
const y = event.clientY - rect.top;
|
||||
const point = this.map.containerPointToLatLng([x, y]);
|
||||
|
||||
this.addMarker(player, point);
|
||||
},
|
||||
|
||||
addMarker(player, latlng) {
|
||||
if (this.markers[player.steam_id_64]) {
|
||||
this.markers[player.steam_id_64].setLatLng(latlng);
|
||||
} else {
|
||||
const displayName = player.username || player.name || player.steam_id_64;
|
||||
const iconHtml = `
|
||||
<div class="flex flex-col items-center justify-center transform hover:scale-110 transition duration-200">
|
||||
<img src="${player.avatar_url || 'https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg'}"
|
||||
class="w-8 h-8 rounded-full border-2 border-white shadow-lg box-content">
|
||||
<span class="mt-1 text-[10px] font-bold text-white bg-black/60 px-1.5 py-0.5 rounded backdrop-blur-sm whitespace-nowrap overflow-hidden max-w-[80px] text-ellipsis">
|
||||
${displayName}
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
const icon = L.divIcon({ className: 'bg-transparent', html: iconHtml, iconSize: [60, 60], iconAnchor: [30, 30] });
|
||||
|
||||
const marker = L.marker(latlng, { icon: icon, draggable: true }).addTo(this.map);
|
||||
this.markers[player.steam_id_64] = marker;
|
||||
this.boardPlayers.push(player);
|
||||
}
|
||||
},
|
||||
|
||||
clearBoard() {
|
||||
for (let id in this.markers) { this.map.removeLayer(this.markers[id]); }
|
||||
this.markers = {};
|
||||
this.boardPlayers = [];
|
||||
},
|
||||
|
||||
saveBoard() {
|
||||
const title = prompt("请输入战术标题:", "New Strat " + new Date().toLocaleTimeString());
|
||||
if (!title) return;
|
||||
|
||||
const markerData = [];
|
||||
for (let id in this.markers) {
|
||||
const m = this.markers[id];
|
||||
markerData.push({ id: id, lat: m.getLatLng().lat, lng: m.getLatLng().lng });
|
||||
}
|
||||
|
||||
fetch('/tactics/save_board', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ title: title, map_name: this.currentMap, markers: markerData })
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => alert(data.success ? "保存成功" : "保存失败"));
|
||||
},
|
||||
|
||||
// --- Economy Logic ---
|
||||
calculateIncome() {
|
||||
let base = 0;
|
||||
const lbLevel = parseInt(this.econ.lossBonus);
|
||||
|
||||
if (this.econ.result === 'win') {
|
||||
base = 3250 + (300 * this.econ.surviving); // Simplified estimate
|
||||
} else {
|
||||
// Loss base
|
||||
const lossAmounts = [1400, 1900, 2400, 2900, 3400];
|
||||
base = lossAmounts[Math.min(lbLevel, 4)];
|
||||
}
|
||||
return base;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
28
web/templates/tactics/layout.html
Normal file
28
web/templates/tactics/layout.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<!-- Navigation Tabs -->
|
||||
<div class="border-b border-gray-200 dark:border-slate-700 mb-6">
|
||||
<nav class="-mb-px flex space-x-8">
|
||||
<a href="{{ url_for('tactics.index') }}" class="border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
|
||||
← Dashboard
|
||||
</a>
|
||||
<a href="{{ url_for('tactics.analysis') }}" class="{{ 'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400' if request.endpoint == 'tactics.analysis' else 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-200' }} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
|
||||
Deep Analysis
|
||||
</a>
|
||||
<a href="{{ url_for('tactics.data') }}" class="{{ 'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400' if request.endpoint == 'tactics.data' else 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-200' }} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
|
||||
Data Center
|
||||
</a>
|
||||
<a href="{{ url_for('tactics.board') }}" class="{{ 'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400' if request.endpoint == 'tactics.board' else 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-200' }} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
|
||||
Strategy Board
|
||||
</a>
|
||||
<a href="{{ url_for('tactics.economy') }}" class="{{ 'border-yrtv-500 text-yrtv-600 dark:text-yrtv-400' if request.endpoint == 'tactics.economy' else 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-200' }} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
|
||||
Economy
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
{% block tactics_content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
27
web/templates/tactics/maps.html
Normal file
27
web/templates/tactics/maps.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white dark:bg-slate-800 shadow rounded-lg p-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">地图情报</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for map in maps %}
|
||||
<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden hover:shadow-lg transition cursor-pointer">
|
||||
<div class="h-40 bg-gray-300 flex items-center justify-center overflow-hidden">
|
||||
<!-- Use actual map images or fallback -->
|
||||
<img src="{{ url_for('static', filename='images/maps/' + map.name + '.jpg') }}"
|
||||
onerror="this.src='https://developer.valvesoftware.com/w/images/thumb/3/3d/De_mirage_radar_spectator.png/800px-De_mirage_radar_spectator.png'; this.style.objectFit='cover'; this.style.height='100%'; this.style.width='100%';"
|
||||
alt="{{ map.title }}" class="w-full h-full object-cover">
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<h3 class="text-lg font-bold text-gray-900 dark:text-white">{{ map.title }}</h3>
|
||||
<div class="mt-4 flex space-x-2">
|
||||
<button class="px-3 py-1 bg-yrtv-100 text-yrtv-700 rounded text-sm hover:bg-yrtv-200">道具点位</button>
|
||||
<button class="px-3 py-1 bg-gray-100 text-gray-700 rounded text-sm hover:bg-gray-200">战术板</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user