Skip to content

Commit 0ebc1bb

Browse files
committed
Merge branch 'master' into forall-change
2 parents 5e6c95e + 7b755ca commit 0ebc1bb

File tree

8 files changed

+106
-39
lines changed

8 files changed

+106
-39
lines changed

base/App/KL/Game/Hero/Croni/hero.kind

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ App.KL.Game.Hero.Croni.hero: App.KL.Game.Hero
4242

4343
let attributes =
4444
some(App.KL.Game.Hero.Attributes.set(
45-
0 // Damage
45+
5 // Damage
4646
1 // Resistance
47-
5 // Mobility
47+
2 // Mobility
4848
5 // Range
49-
5 // Utility
50-
3 // Difficulty
49+
2 // Utility
50+
4 // Difficulty
5151
))
5252

5353
let role = some(App.KL.Game.Hero.Role.ranged)

base/App/KL/Game/Phase/Play/Bar/show_hp.kind

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
App.KL.Game.Phase.Play.Bar.show_hp(
22
cx: U32,
3-
cy: U32,
3+
cy: U32,
4+
user_id: String,
5+
team: App.KL.Game.Team,
46
creature: App.KL.Game.Creature,
57
img: VoxBox
68
): VoxBox
@@ -10,11 +12,18 @@ App.KL.Game.Phase.Play.Bar.show_hp(
1012
let shield = App.KL.Game.Creature.Status.shield.total(creature)
1113

1214
if I32.gtn(creature.hp, 0) then
13-
let col = case creature.team {
14-
red: Col32.new(200, 20, 20, 255)
15-
blue: Col32.new(20, 200, 200, 255)
16-
neutral: Col32.new(100, 20, 100, 255)
17-
}
15+
let col =
16+
if String.eql(user_id, creature@player <> "") then
17+
Col32.new(255, 255, 20, 255) // Yellow
18+
else
19+
if App.KL.Game.Team.eql(team, creature@team) then
20+
Col32.new(20, 200, 200, 255) // Blue
21+
else
22+
if App.KL.Game.Team.eql(App.KL.Game.Team.neutral, creature@team) then
23+
Col32.new(100, 20, 100, 255) // gray
24+
else
25+
Col32.new(200, 20, 20, 255) // red
26+
1827
let bar = App.KL.Game.Phase.Play.Bar.Progress.new(
1928
I32.to_u32(hero.max_hp),
2029
I32.to_u32(creature.hp),

base/App/KL/Game/Phase/Play/draw/canvas.kind

+34-17
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ App.KL.Game.Phase.Play.draw.canvas.board(
6363
img: VoxBox
6464
): VoxBox
6565
open game
66+
let team = App.KL.Game.Phase.Draft.to_team(game@players, user) <> App.KL.Game.Team.neutral
6667
let map = game@board
6768
let mouse_coord = Hexagonal.Axial.from_screen_xy(mouse, App.KL.Constants.hexagon_radius, U32.to_i32(screen@fst) / 4, U32.to_i32(screen@snd) / 4)
6869
let indicators = App.KL.Game.Phase.Play.Draw.canvas.get_indicators(preview, mouse_coord, user, game)
@@ -74,8 +75,8 @@ App.KL.Game.Phase.Play.draw.canvas.board(
7475
let img = App.KL.Game.Phase.Play.draw.canvas.grid(coord, game@moment, screen, img)
7576
let img = App.KL.Game.Phase.Play.draw.canvas.tile.terrain(tile@terrain, preview@picks, indicator, coord, screen, img)
7677
let img = App.KL.Game.Phase.Play.draw.canvas.tile.indicator(indicator, coord, screen, img)
77-
let img = App.KL.Game.Phase.Play.draw.canvas.tile.creature(game, tile@creature, coord, ap_used, screen, img)
78-
let img = App.KL.Game.Phase.Play.draw.canvas.tile.token(game, tile@token, coord, screen, img)
78+
let img = App.KL.Game.Phase.Play.draw.canvas.tile.creature(game, tile@creature, coord, ap_used, screen, user, img)
79+
let img = App.KL.Game.Phase.Play.draw.canvas.tile.token(game, tile@token, coord, screen, team, img)
7980
img
8081
img
8182

@@ -102,26 +103,40 @@ App.KL.Game.Phase.Play.draw.canvas.tile.token(
102103
token: Maybe<App.KL.Game.Token>,
103104
token_coord: Hexagonal.Axial,
104105
screen: Pair<U32, U32>
106+
team: App.KL.Game.Team
105107
img: VoxBox
106108
): VoxBox
107109
without token: img
108-
let col = case App.KL.Game.Token.get_dominance(token) as team {
109-
none: Col32.new(100,100,100,255)
110-
some:
111-
case team.value {
112-
blue: Col32.new(0, 0, 255, 255)
113-
red: Col32.new(255, 0, 0, 255)
114-
} default Col32.new(100,100,100,255)
115-
}
110+
let col =
111+
case App.KL.Game.Token.get_dominance(token) as team {
112+
none: Col32.new(100,100,100,255)
113+
some:
114+
if App.KL.Game.Team.eql(team, team.value) then
115+
Col32.new(0, 0, 255, 255)
116+
else
117+
if App.KL.Game.Team.eql(App.KL.Game.Team.neutral, team.value) then
118+
Col32.new(100,100,100,255)
119+
else
120+
Col32.new(255, 0, 0, 255)
121+
}
122+
116123
let coords = Hexagonal.Axial.range(token_coord, token@range)
124+
let board = game@board
117125
for coord in coords with img:
118-
let {cx, cy} =
119-
Hexagonal.Axial.to_screen_xy(coord, App.KL.Constants.hexagon_radius, U32.to_i32(screen@fst) / 4, U32.to_i32(screen@snd) / 4)
126+
let tile = Hexagonal.Axial.Map.get!(coord, board)
127+
case tile {
128+
none:
129+
img
130+
some:
131+
let {cx, cy} =
132+
Hexagonal.Axial.to_screen_xy(coord, App.KL.Constants.hexagon_radius, U32.to_i32(screen@fst) / 4, U32.to_i32(screen@snd) / 4)
133+
134+
if Hexagonal.Axial.eql(coord, token_coord) then
135+
VoxBox.Draw.square(cx,cy,App.KL.Constants.z_index.token,10,10,col,img)
136+
else
137+
VoxBox.Draw.square(cx,cy,App.KL.Constants.z_index.token,5,5,col,img)
138+
}
120139

121-
if Hexagonal.Axial.eql(coord, token_coord) then
122-
VoxBox.Draw.square(cx,cy,App.KL.Constants.z_index.token,10,10,col,img)
123-
else
124-
VoxBox.Draw.square(cx,cy,App.KL.Constants.z_index.token,5,5,col,img)
125140
img
126141

127142

@@ -268,11 +283,13 @@ App.KL.Game.Phase.Play.draw.canvas.tile.creature(
268283
coord: Hexagonal.Axial,
269284
ap_used: Maybe<Pair<String, I32>>
270285
screen: Pair<U32,U32>
286+
user_id: String
271287
img: VoxBox
272288
): VoxBox
273289
case creature {
274290
none: img
275291
some:
292+
let team = App.KL.Game.Phase.Draft.to_team(game@players, user_id)
276293
let hero = creature.value@hero
277294
let draw_pose = App.KL.Game.Phase.Play.draw.canvas.tile.creature.get_draw_pose(game, coord)
278295
let {draw_coord, draw_voxbox} = hero@draw@vbox_img(draw_pose)
@@ -291,7 +308,7 @@ App.KL.Game.Phase.Play.draw.canvas.tile.creature(
291308
none:
292309
img
293310
some:
294-
let img = App.KL.Game.Phase.Play.Bar.show_hp(cx - 17, (cy - height), creature.value, img)
311+
let img = App.KL.Game.Phase.Play.Bar.show_hp(cx - 17, (cy - height), user_id, team <> App.KL.Game.Team.neutral, creature.value, img)
295312
let img = App.KL.Game.Phase.Play.draw.ap(img_x - 12, (img_y - height) - 3, creature.value, ap_used, img)
296313
img
297314
}

base/App/KL/Game/Phase/Play/draw/interface.kind

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ App.KL.Game.Phase.Play.draw.interface.top.creature(creature: Maybe<App.KL.Game.C
236236
"right":" 0"
237237
"text-align":" center"
238238
"color": "white"
239-
}> String.show_clean(I32.show(dead.value@snd)) | " TURNS"</span>
239+
}> String.show_clean(I32.show(dead.value@snd + 1)) | " TURNS"</span>
240240
</div>
241241
}
242242
}

base/App/KL/Game/Phase/Play/when.kind

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ App.KL.Game.Phase.Play.when(
99
open game
1010
case event {
1111
frame:
12+
open event.info
1213
log("Screen size: " | U32.show(local@screen_size@fst) | ", " | U32.show(local@screen_size@snd))
1314
let picks = App.KL.Game.Cast.picks_of(local@user, game)
1415
let new_local = local@preview <- (local@preview@picks <- picks)
15-
let new_local = new_local@screen_size <- event.info@screen_size
16+
let new_local = new_local@screen_size <- event.info.screen_size
1617
App.set_local!(App.KL.State.Local.game(new_local))
1718
mouse_move:
1819
// mouse move on canvas

base/App/KL/Lobby.kind

+7-7
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ App.KL.Lobby.draw.front(user: String, room_input: String, global: App.KL.Global.
233233
<div>
234234
{App.KL.Lobby.draw.front.button("ready", "Enter")}
235235
//{App.KL.Lobby.draw.front.button("random", "Random")}
236-
{App.KL.Lobby.draw.front.button("heroes", "Heroes")}
236+
//{App.KL.Lobby.draw.front.button("heroes", "Heroes")}
237237
</div>
238238
</div>
239239
<pre style={"margin-top": "30px", "font-size": "medium", "text-align": "start"}>
@@ -287,12 +287,12 @@ App.KL.Lobby.when(
287287
App.set_local<App.KL.State>(App.KL.State.Local.game(App.KL.Game.State.Local.init(local@user, page.room_input, local@screen_size)))
288288
}
289289
}
290-
"heroes": IO {
291-
let new_page = App.KL.Lobby.State.Local.Page.heroes(none, none, "string")
292-
let new_local = local@page <- new_page
293-
App.set_local<App.KL.State>(App.KL.State.Local.lobby(new_local))
294-
}
295-
}default App.pass!
290+
// "heroes": IO {
291+
// let new_page = App.KL.Lobby.State.Local.Page.heroes(none, none, "string")
292+
// let new_local = local@page <- new_page
293+
// App.set_local<App.KL.State>(App.KL.State.Local.lobby(new_local))
294+
// }
295+
}default App.pass<App.KL.State>
296296
heroes:
297297
switch String.starts_with(event.id) {
298298
"H":

base/Bits/and.kind

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Bits.and(a: Bits, b: Bits): Bits
22
case a {
3-
e: b,
3+
e: a,
44
o: case b {
5-
e: a,
5+
e: b,
66
o: Bits.o(Bits.and(a.pred, b.pred)),
77
i: Bits.o(Bits.and(a.pred, b.pred))
88
}
99
i: case b {
10-
e: a,
10+
e: b,
1111
o: Bits.o(Bits.and(a.pred, b.pred)),
1212
i: Bits.i(Bits.and(a.pred, b.pred))
1313
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
List.agroup(A : Type, list : List<A>) : List<Pair<A, A>>
2+
case list {
3+
cons : case list.tail {
4+
cons : {list.head, list.tail.head} & List.agroup!(list.tail.tail)
5+
nil : []
6+
}
7+
nil : []
8+
}
9+
10+
Ether.Address.Checksum.bits(value : String): List<Bits> // refinement for all char in value, value is lower
11+
let value = Crypto.Keccak.hash(value)
12+
let value = String.fold(value, _, [], (c, xs) String.cons(c, String.nil) & xs)
13+
List.map!!(Bits.hex.decode . (String.reverse . String.join("")), List.chunks_of!(2, value))
14+
15+
Ether.Address.Checksum.generate(encoding : List<Pair<Bits, Pair<String, String>>>) : String
16+
case encoding {
17+
cons :
18+
let {hash, chars} = encoding.head
19+
let {char, char1} = chars
20+
let str = Ether.Address.Checksum.generate(encoding.tail)
21+
22+
str = if Bits.lte(Nat.to_bits(8), Bits.and(Nat.to_bits(15), hash)) then
23+
String.to_upper(char1) | str
24+
else
25+
String.to_lower(char1) | str
26+
27+
str = if Bits.lte(Nat.to_bits(8), Bits.shift_right(4, hash)) then
28+
String.to_upper(char) | str
29+
else
30+
String.to_lower(char) | str
31+
str
32+
nil : ""
33+
}
34+
35+
Ether.Address.Checksum.encode(address : String) : String
36+
let xs = Ether.Address.Checksum.bits(address)
37+
let address = String.fold(address, _, [], (c, xs) String.cons(c, String.nil) & xs)
38+
let encoder = List.zip!!(List.take!(40, xs), List.agroup!(address))
39+
Ether.Address.Checksum.generate(encoder)
40+

0 commit comments

Comments
 (0)