-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
182 lines (152 loc) · 9.03 KB
/
index.html
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
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div id="app" style="display: flex">
<div class="modal" v-bind:class="{visible: joinModalVisible}" v-on:click.self="hideJoinModal">
<div class="modal-body">
<h2> Join the game </h2>
<input class="fancy-input" type="text" id="fname" placeholder="Your name" name="fname" v-model=player.name>
<div class="color-squares" v-for="color in colors">
<div class="color-square" :style="{ 'background-color': color.code, 'border-color': player.color == color.code ? 'steelblue' : color.code }" v-on:click="selectColor($event, color)">
</div>
</div>
<button v-on:click="hideJoinModal"> Cancel </button>
<button v-on:click="joinGame"> Join </button>
</div>
</div>
<div class="info" style="display: flex; flex-direction: column">
<div class="title" style="padding: 18px; display: flex">
<span style="margin-right: 12px; font-size: 1.8rem; font-weight: 600"> Catan </span>
<div v-if="connection_status == 'CONNECTED'" style="display: flex; align-items: center; flex: 2">
<div style="width: 12px; height: 12px; border-radius: 50%; background-color: rgb(118, 204, 19)"></div>
</div>
<div v-else style="display: flex; align-items: center; flex: 2">
<div style="width: 12px; height: 12px; border-radius: 50%; background-color: red"></div>
</div>
<div style="display: flex; align-items: center; color: gray">
{{T(status)}}
</div>
</div>
<div class="players" style="padding: 18px; ">
<div v-if="players.length">
<div v-for="player in players">
<div style="background: white; margin-bottom: 12px; border-radius: 2px; padding:12px; ">
<div style="display:flex; align-items: center; padding-bottom: 2px; border-bottom: 1px solid whitesmoke;">
<span style="margin: 4px 4px; flex: 3; font-weight: 100 "
:style="{ 'color': player.attributes.color }"> {{player.attributes.name}} <small>({{player.attributes.id}})</small></span>
<div v-if="player.attributes.id == currentPlayerId"
style="display: flex; align-items: center;">
<div style="width: 6px; height: 6px; border-radius: 50%; background-color: steelblue"></div>
</div>
</div>
<div style="display:flex; padding-top: 4px; justify-content: flex-start;">
<div style="flex-grow: 1">
<small>Resources</small>
<div style="width: 100%; display: flex;">
<div v-for="resource in player.attributes.resources" style="display: flex;">
<div v-if="resource.value!=0">
<div style="font-weight: 100; width: 18px; height: 28px; border-radius: 5%; margin-right: 4px; display: flex; align-items: center; justify-content: center;"
class="resource" v-bind:class="resource.type"> {{resource.value}}
</div>
</div>
</div>
</div>
</div>
<div style="align-self: flex-start">
<small>Developmentcards ({{player.attributes.unused_development_cards}})</small>
<div style="width: 100%; display: flex;">
<div v-for="developmentcard in player.attributes.used_development_cards"
style="display: flex">
<div v-if="developmentcard.value!=0">
<div style="font-weight: 100; width: 18px; height: 28px; border-radius: 5%; margin-right: 4px; display: flex; align-items: center; justify-content: center;"
class="developmentcard" v-bind:class="developmentcard.type">
{{developmentcard.value}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div v-else>
<strong> No players connected </strong>
</div>
</div>
<div id="events" class="events"
style="padding: 18px; display: flex; flex-direction: column-reverse; flex:3">
<div v-for="(event, index) in events" style="padding-bottom: 8px"
v-bind:style="[event.attributes.moveCount >= json.attributes.moveCount ? {'font-weight': 600} : {}]">
<span v-if="event.attributes.player_full"
:style="{ 'color': event.attributes.player_full.attributes.color }">
{{event.attributes.player_full.attributes.name}}
</span>
<span v-if="event.attributes.event_type=='GENERAL'" style="font-style: italic;">
{{event.attributes.message}}
</span>
<span v-if="event.attributes.event_type == 'BUILD'">
<span v-if="event.attributes.structures.length">
builds
<span v-for="structure in event.attributes.structures"> {{structure}} </span>
</span>
<span v-else>
builds nothing
</span>
</span>
<span v-else-if="event.attributes.event_type == 'GET_RESOURCES'" style="font-style: italic;">
<span v-if="event.attributes.resources.length">
receives
<span v-for="resource in event.attributes.resources">
<span class="resource-txt" v-bind:class="resource.type"> {{resource.value}} {{resource.type}} </span>
</span>
</span>
<span v-else>
receives nothing
</span>
</span>
<span v-else-if="event.attributes.event_type == 'TRADE'">
<span v-if="event.attributes.resources.length">
trades
<span v-for="resource in event.attributes.resources">
<span class="resource-txt" v-bind:class="resource.type"> {{resource.value}} {{resource.type}} </span>
</span>
</span>
<span v-else>
receives nothing
</span>
</span>
</div>
</div>
<div class="connect" style="padding: 18px;">
<input v-on:keyup.enter="connect" v-model="ip" style=" width: 100%; margin-bottom: 12px;">
<div style="display: flex; width: 100%; margin-bottom: 12px;">
<input v-on:keyup.enter="connect" v-model="port" style="flex: 2; margin-right: 8px;">
<button v-on:click="connect">Connect</button>
<br>
</div>
<div v-if="status==='GAME_RUNNING'" style="display: flex; width: 100%">
<button v-on:click="endGame" style="justify-content: center; width: 100%;">Stop game
</button>
</div>
<div v-else-if="status==='WAITING_FOR_TAKEOFF'" style=" width: 100%">
<button v-on:click="showJoinModal" style="justify-content: center; width: 100%; "> Join game </button>
<button v-on:click="startGame" style="justify-content: center; width: 100%; ">Start game </button>
</div>
<div v-else="status==='WAITING_FOR_TAKEOFF'" style=" width: 100%">
<button v-on:click="showJoinModal" style="justify-content: center; width: 100%; "> Join game </button>
</div>
</div>
</div>
<div class="board">
<div id="d3-holder"></div>
</div>
</div>
</body>
<script src="translations.js"></script>
<script src="script.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>