remove let omit from parser

This commit is contained in:
rheidner 2021-10-20 14:38:45 -03:00
parent 2b2132086f
commit 6e559aaad9
128 changed files with 15985 additions and 16526 deletions

View File

@ -1,5 +1,5 @@
App.ATB.Hero.char_1: App.ATB.Hero.hero_type
char_id = "char_1"
name = "Personagem 1"
hp_max = 50
let char_id = "char_1"
let name = "Personagem 1"
let hp_max = 50
App.ATB.Hero.hero_type.new(char_id, name, hp_max, hp_max)

View File

@ -1,5 +1,5 @@
App.ATB.Hero.char_2: App.ATB.Hero.hero_type
char_id = "char_2"
name = "Personagem 2"
hp_max = 100
let char_id = "char_2"
let name = "Personagem 2"
let hp_max = 100
App.ATB.Hero.hero_type.new(char_id, name, hp_max, hp_max)

View File

@ -1,5 +1,5 @@
App.ATB.Hero.char_3: App.ATB.Hero.hero_type
char_id = "char_3"
name = "Personagem 3"
hp_max = 110
let char_id = "char_3"
let name = "Personagem 3"
let hp_max = 110
App.ATB.Hero.hero_type.new(char_id, name, hp_max, hp_max)

View File

@ -112,28 +112,28 @@ App.BoardBuilder.Builder.When(
}default App.pass!
mouse_down:
new_local = local@mouse_press <- true
let new_local = local@mouse_press <- true
App.set_local!(App.BoardBuilder.State.local.builder(new_local))
mouse_up:
new_local = local@mouse_press <- false
let new_local = local@mouse_press <- false
App.set_local!(App.BoardBuilder.State.local.builder(new_local))
key_up:
log(U16.show(event.code))
switch U16.eql(event.code) {
16#16:
new_local = local@show_grid <- false
let new_local = local@show_grid <- false
App.set_local!(App.BoardBuilder.State.local.builder(new_local))
}default App.pass!
key_down:
switch U16.eql(event.code) {
16#16:
new_local = local@show_grid <- true
let new_local = local@show_grid <- true
App.set_local!(App.BoardBuilder.State.local.builder(new_local))
17#16:
new_local = local@show_grid <- not(local@show_grid)
let new_local = local@show_grid <- not(local@show_grid)
App.set_local!(App.BoardBuilder.State.local.builder(new_local))
}default
let new_local = local@command <- event.code

View File

@ -6,22 +6,22 @@ App.BoardBuilder.Post: App.Post<App.BoardBuilder.State>
some:
case eventglob.value as event {
terrain_add:
glob = glob@terrains <- Hexagonal.Axial.Map.set!(event.coord, App.KL.Game.Terrain.new(event.field_id, none), glob@terrains)
glob = glob@landscape <- Hexagonal.Axial.Map.delete!(event.coord, glob@landscape)
let glob = glob@terrains <- Hexagonal.Axial.Map.set!(event.coord, App.KL.Game.Terrain.new(event.field_id, none), glob@terrains)
let glob = glob@landscape <- Hexagonal.Axial.Map.delete!(event.coord, glob@landscape)
glob
terrain_del:
glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
let glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
let glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
let glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
glob
landscape_add:
glob = glob@landscape <- Hexagonal.Axial.Map.set!(event.coord, App.KL.Game.Terrain.new(event.field_id, none), glob@landscape)
glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
let glob = glob@landscape <- Hexagonal.Axial.Map.set!(event.coord, App.KL.Game.Terrain.new(event.field_id, none), glob@landscape)
let glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
let glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
let glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
glob
landscape_del:
glob = glob@landscape <- Hexagonal.Axial.Map.delete!(event.coord, glob@landscape)
let glob = glob@landscape <- Hexagonal.Axial.Map.delete!(event.coord, glob@landscape)
glob
bases_add:
case Hexagonal.Axial.Map.get!(event.coord, glob@terrains) {
@ -33,10 +33,10 @@ App.BoardBuilder.Post: App.Post<App.BoardBuilder.State>
bases_del:
glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
initial_add:
glob = glob@initial <- Hexagonal.Axial.Map.set!(event.coord, event.team, glob@initial)
glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
let glob = glob@initial <- Hexagonal.Axial.Map.set!(event.coord, event.team, glob@initial)
let glob = glob@terrains <- Hexagonal.Axial.Map.delete!(event.coord, glob@terrains)
let glob = glob@bases <- Hexagonal.Axial.Map.delete!(event.coord, glob@bases)
let glob = glob@tokens <- Hexagonal.Axial.Map.delete!(event.coord, glob@tokens)
glob
initial_del:
glob@initial <- Hexagonal.Axial.Map.delete!(event.coord, glob@initial)

View File

@ -1,21 +1,21 @@
App.Drawing.Action.local.ctrl_z(local: App.Drawing.State.local): App.Drawing.State.local
open local
open local.whiteboard as wb
past = List.tail!(wb.past)
let past = List.tail!(wb.past)
case past {
nil:
log("nil")
local
cons:
log("cons")
square = VoxBox.Draw.square(126, 126, 0, 20, 20, Col32.new(0#32,255#32,0#32,125#32), wb.live)
let square = VoxBox.Draw.square(126, 126, 0, 20, 20, Col32.new(0#32,255#32,0#32,125#32), wb.live)
log("past_length: " | Nat.show(List.length!(past)))
live = List.head!(past) <> square
cleared = VoxBox.clear(live)
live = VoxBox.Draw.image(0, 0, 0, live, cleared)
future = wb.live & wb.future
wb = App.Drawing.Whiteboard.new(past, live, future)
new_local = local@whiteboard <- wb
let live = List.head!(past) <> square
let cleared = VoxBox.clear(live)
let live = VoxBox.Draw.image(0, 0, 0, live, cleared)
let future = wb.live & wb.future
let wb = App.Drawing.Whiteboard.new(past, live, future)
let new_local = local@whiteboard <- wb
new_local
}

View File

@ -1,9 +1,9 @@
App.Drawing.Action.local.save(local: App.Drawing.State.local): App.Drawing.State.local
open local
open local.whiteboard as wb
past = wb.live & wb.past
live = wb.live
future = []
let past = wb.live & wb.past
let live = wb.live
let future = []
log(Nat.show(List.length!(past)))
whiteboard = App.Drawing.Whiteboard.new(past,live,future)
let whiteboard = App.Drawing.Whiteboard.new(past,live,future)
local@whiteboard <- whiteboard

View File

@ -1,18 +1,18 @@
App.Drawing.App.init(img: VoxBox): App.Init<App.Drawing.State>
room = App.Drawing.Constants.room
players = Map.new!
phase = App.Drawing.Phase.active(0)
arts = [] :: List<Map<App.Drawing.Board>>
stage = App.Drawing.Stage.boards(phase, [])
let room = App.Drawing.Constants.room
let players = Map.new!
let phase = App.Drawing.Phase.active(0)
let arts = [] :: List<Map<App.Drawing.Board>>
let stage = App.Drawing.Stage.boards(phase, [])
input = ""
let input = ""
user = ""
env_info = App.EnvInfo.new({256, 256}, {0, 0})
tool = App.Drawing.Tool.pencil
size = 3 :: U32
color = Col32.new(255#32,0#32,0#32,125#32)
whiteboard = App.Drawing.Whiteboard.new([img], img, [])
style = App.Drawing.Style.new(tool, size, color)
let env_info = App.EnvInfo.new({256, 256}, {0, 0})
let tool = App.Drawing.Tool.pencil
let size = 3 :: U32
let color = Col32.new(255#32,0#32,0#32,125#32)
let whiteboard = App.Drawing.Whiteboard.new([img], img, [])
let style = App.Drawing.Style.new(tool, size, color)
App.Store.new!(

View File

@ -1,6 +1,6 @@
App.Drawing.App.when: App.When<App.Drawing.State>
(event, state)
stage = state@global@stage
let stage = state@global@stage
case stage {
boards: App.Drawing.when.boards(event, state)
}default App.pass!

View File

@ -1,5 +1,5 @@
App.Drawing.draw.boards(img: VoxBox, state: App.Store<App.Drawing.State>): VoxBox
local = state@local
whiteboard = local@whiteboard
img = VoxBox.clear(img)
let local = state@local
let whiteboard = local@whiteboard
let img = VoxBox.clear(img)
VoxBox.Draw.image(0, 0, 0, whiteboard@live, img)

View File

@ -1,11 +1,11 @@
App.Drawing.draw.pencil(local: App.Drawing.State.local): App.Drawing.State.local
log("push")
style = local@style
size = style@size
wb = local@whiteboard
info = local@env_info@mouse_pos
color = style@color
new_board = VoxBox.Draw.square(info@fst, info@snd, 0, size, size, color, wb@live)
new_wb = wb@live <- new_board
let style = local@style
let size = style@size
let wb = local@whiteboard
let info = local@env_info@mouse_pos
let color = style@color
let new_board = VoxBox.Draw.square(info@fst, info@snd, 0, size, size, color, wb@live)
let new_wb = wb@live <- new_board
local@whiteboard <- new_wb

View File

@ -1,25 +1,25 @@
App.Drawing.when.boards(event: App.Event, state: App.Store<App.Drawing.State>): IO(Maybe(App.State.local(App.Drawing.State)))
local = state@local
let local = state@local
case event{
key_down:
//log(U16.show(event.code))
switch U16.eql(event.code) {
'A':
style = local@style
style = style@color <- Col32.new(0#32,0#32,255#32,255#32)
new_local = local@style <- style
let style = local@style
let style = style@color <- Col32.new(0#32,0#32,255#32,255#32)
let new_local = local@style <- style
App.set_local!(new_local)
'S':
style = local@style
style = style@color <- Col32.new(255#32,0#32,0#32,255#32)
new_local = local@style <- style
let style = local@style
let style = style@color <- Col32.new(255#32,0#32,0#32,255#32)
let new_local = local@style <- style
App.set_local!(new_local)
'Z':
App.set_local!(App.Drawing.Action.local.ctrl_z(local))
}default App.pass!
mouse_down:
new_local = local@drawing <- true
let new_local = local@drawing <- true
App.set_local!(new_local)
frame:
@ -32,8 +32,8 @@ case event{
App.set_local!(new_local)
mouse_up:
new_local = local@drawing <- false
new_local = App.Drawing.Action.local.save(new_local)
let new_local = local@drawing <- false
let new_local = App.Drawing.Action.local.save(new_local)
App.set_local!(new_local)

View File

@ -3,6 +3,6 @@ App.KL.Game.Areas.circle(
radius: I32
): List<Hexagonal.Axial>
circle = Hexagonal.Axial.range(coord, radius)
let circle = Hexagonal.Axial.range(coord, radius)
circle

View File

@ -4,5 +4,5 @@ App.KL.Game.Areas.straight_line(
goal: Hexagonal.Axial
): List<Hexagonal.Axial>
direction = Hexagonal.Axial.clamp(1, origin, goal)
let direction = Hexagonal.Axial.clamp(1, origin, goal)
Hexagonal.Axial.line_by_direction(size, origin, direction)

View File

@ -16,7 +16,7 @@ type App.KL.Game.Board.Blueprint {
App.KL.Game.Board.Blueprint.build.terrains(
terrains: List<Pair<Pair<I32, I32>, Nat>> // {coord, field_id}
): Hexagonal.Axial.Map<App.KL.Game.Terrain>
map = Hexagonal.Axial.Map.new!
let map = Hexagonal.Axial.Map.new!
for tile in terrains with map:
let coord = Hexagonal.Axial.new(tile@fst@fst, tile@fst@snd)
let terrain = App.KL.Game.Terrain.new(tile@snd, none)
@ -26,7 +26,7 @@ App.KL.Game.Board.Blueprint.build.terrains(
App.KL.Game.Board.Blueprint.build.tokens(
tokens: List<Pair<Pair<I32, I32>, App.KL.Game.Token>> // {coord, token}
): Hexagonal.Axial.Map<App.KL.Game.Token>
map = Hexagonal.Axial.Map.new!
let map = Hexagonal.Axial.Map.new!
for tile in tokens with map:
let coord = Hexagonal.Axial.new(tile@fst@fst, tile@fst@snd)
let token = tile@snd

View File

@ -4,7 +4,7 @@ App.KL.Game.Board.Creature.change_hp(
board: App.KL.Game.Board
): Pair<I32, Pair<App.KL.Game.Board, Maybe<String>>>
creature = App.KL.Game.Board.Creature.get(pos, board)
let creature = App.KL.Game.Board.Creature.get(pos, board)
without creature: {+0#32, {board, none}}
let max_hp = App.KL.Game.Board.Creature.get.max_hp(creature)
let new_hp = I32.max((creature@hp + value) , 0)

View File

@ -5,7 +5,7 @@ App.KL.Game.Board.Creature.modify_at(
board: App.KL.Game.Board
): App.KL.Game.Board
result = Maybe {
let result = Maybe {
let key = Hexagonal.Axial.to_nat(pos)
get tile = App.KL.Game.Tile.get(pos, board)
get creature = tile@creature

View File

@ -6,7 +6,7 @@ App.KL.Game.Board.apply_status(
for coord:tile in game@board with result:
// Applies Tile's Effect if it has one
result = Maybe {
let result = Maybe {
get effect = tile@effect
let activation = effect@activation
let result = case activation {

View File

@ -5,25 +5,25 @@ App.KL.Game.Board.push(
board : App.KL.Game.Board
): App.KL.Game.Board
tile = App.KL.Game.Tile.get(coord, board)
let tile = App.KL.Game.Tile.get(coord, board)
case tile {
none:
case entity {
terrain:
new_tile = App.KL.Game.Tile.new(entity.value, none, none, none)
let new_tile = App.KL.Game.Tile.new(entity.value, none, none, none)
App.KL.Game.Board.set(coord, new_tile, board)
} default board
some:
open tile.value as tile
case entity {
terrain:
background_tile = tile.value@background <- entity.value
let background_tile = tile.value@background <- entity.value
App.KL.Game.Board.set(coord, background_tile, board)
creature:
creature_tile = tile.value@creature <- some(entity.value)
let creature_tile = tile.value@creature <- some(entity.value)
App.KL.Game.Board.set(coord, creature_tile, board)
token:
token_tile = tile.value@token <- some(entity.value)
let token_tile = tile.value@token <- some(entity.value)
App.KL.Game.Board.set(coord, token_tile, board)
}
}

View File

@ -33,7 +33,7 @@ App.KL.Game.Cast.picks_of(
App.KL.Game.Cast.picks_of.aux(targets: List<Hexagonal.Axial>, idx: Nat, pattern: App.KL.Game.Skill.Pattern): Maybe<Hexagonal.Axial>
case pattern {
vector:
target = targets[1]
let target = targets[1]
case target {
none: targets[0]
some: target

View File

@ -11,8 +11,8 @@ App.KL.Game.Cast.sort(game: App.KL.Game): List<App.KL.Game.Cast>
case App.KL.Game.Cast.get_skill(cast, game) as got_skill {
none: {seen, casts}
some:
pattern = App.KL.Game.Skill.get_pattern(got_skill.value)
cast = cast@target <- List.take!(pattern, cast@target)
let pattern = App.KL.Game.Skill.get_pattern(got_skill.value)
let cast = cast@target <- List.take!(pattern, cast@target)
{seen, {cast, got_skill.value@delay} & casts}
}
some: {seen, casts}

View File

@ -24,7 +24,7 @@ App.KL.Game.Creature.Status.block.add.aux(
cons:
case status.head {
block:
is_same = String.eql(id, status.head.id)
let is_same = String.eql(id, status.head.id)
if is_same then
status
else

View File

@ -4,7 +4,7 @@ App.KL.Game.Creature.Status.block.verifier(
): Bool
let caster_name = App.KL.Game.Board.Creature.get.name(caster)
denied = App.KL.Game.Creature.Status.block.check(denied)
let denied = App.KL.Game.Creature.Status.block.check(denied)
let result = false
for target in denied with result:
let affected = target@fst // Verifies if the Target is affected by block

View File

@ -17,14 +17,14 @@ App.KL.Game.Creature.Status.dot.add.aux(
status: List<App.KL.Game.Creature.Status>
): List<App.KL.Game.Creature.Status>
new_dot = App.KL.Game.Creature.Status.dot(cast_data, id, duration, 1, amount)
let new_dot = App.KL.Game.Creature.Status.dot(cast_data, id, duration, 1, amount)
case status {
nil:
new_dot & status
cons:
case status.head {
dot:
is_same = String.eql(id, status.head.id)
let is_same = String.eql(id, status.head.id)
if is_same then
let dot_duration = status.head.duration + 1
let dot_stacks = status.head.stack + 1

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.dot.total(
creature: App.KL.Game.Creature
): I32
total_dot = +0#32
let total_dot = +0#32
for status in creature@status with total_dot:
case status {
dot:

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.haste.total(
creature: App.KL.Game.Creature
): I32
total_haste = +0#32
let total_haste = +0#32
for haste in creature@status with total_haste:
case haste {
haste:

View File

@ -18,14 +18,14 @@ App.KL.Game.Creature.Status.hot.add.aux(
status: List<App.KL.Game.Creature.Status>
): List<App.KL.Game.Creature.Status>
new_hot = App.KL.Game.Creature.Status.hot(cast_data, id, duration, 1, amount)
let new_hot = App.KL.Game.Creature.Status.hot(cast_data, id, duration, 1, amount)
case status {
nil:
new_hot & status
cons:
case status.head {
hot:
is_same = String.eql(id, status.head.id)
let is_same = String.eql(id, status.head.id)
if is_same then
let hot_duration = status.head.duration + 1
let hot_stacks = status.head.stack + 1

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.hot.total(
creature: App.KL.Game.Creature
): I32
total_hot = +0#32
let total_hot = +0#32
for status in creature@status with total_hot:
case status {
hot:

View File

@ -15,7 +15,7 @@ App.KL.Game.Creature.Status.invulnerable.add.aux(
status: List<App.KL.Game.Creature.Status>
): List<App.KL.Game.Creature.Status>
new_invulnerable = App.KL.Game.Creature.Status.invulnerable(cast_data, id, duration)
let new_invulnerable = App.KL.Game.Creature.Status.invulnerable(cast_data, id, duration)
case status {
nil:
new_invulnerable & status

View File

@ -5,7 +5,7 @@ App.KL.Game.Creature.Status.protect.add(
amount: I32
): App.KL.Game.Creature
protect_added = App.KL.Game.Creature.Status.protect.add.aux(cast_data, duration, amount, creature@status)
let protect_added = App.KL.Game.Creature.Status.protect.add.aux(cast_data, duration, amount, creature@status)
creature@status <- protect_added
App.KL.Game.Creature.Status.protect.add.aux(

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.protect.update(
creature: App.KL.Game.Creature
): App.KL.Game.Creature
protect_updated = App.KL.Game.Creature.Status.protect.update.aux(creature@status)
let protect_updated = App.KL.Game.Creature.Status.protect.update.aux(creature@status)
creature@status <- protect_updated
App.KL.Game.Creature.Status.protect.update.aux(

View File

@ -4,7 +4,7 @@ App.KL.Game.Creature.Status.root.add(
duration: I32
): App.KL.Game.Creature
root_added = App.KL.Game.Creature.Status.root.add.aux(cast_data, duration, creature@status)
let root_added = App.KL.Game.Creature.Status.root.add.aux(cast_data, duration, creature@status)
creature@status <- root_added
App.KL.Game.Creature.Status.root.add.aux(

View File

@ -6,7 +6,7 @@ App.KL.Game.Creature.Status.shield.add(
amount: I32
): App.KL.Game.Creature
shield_added = App.KL.Game.Creature.Status.shield.add.aux(cast_data, id, duration, amount, creature@status)
let shield_added = App.KL.Game.Creature.Status.shield.add.aux(cast_data, id, duration, amount, creature@status)
creature@status <- shield_added
@ -19,14 +19,14 @@ App.KL.Game.Creature.Status.shield.add.aux(
status: List<App.KL.Game.Creature.Status>
): List<App.KL.Game.Creature.Status>
new_shield = App.KL.Game.Creature.Status.shield(cast_data, id, duration, amount)
let new_shield = App.KL.Game.Creature.Status.shield(cast_data, id, duration, amount)
case status {
nil:
new_shield & status
cons:
case status.head {
shield:
is_same = String.eql(id, status.head.id)
let is_same = String.eql(id, status.head.id)
if is_same then
new_shield & status.tail
else

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.shield.total(
creature: App.KL.Game.Creature
): I32
total_shield = +0#32
let total_shield = +0#32
for shield in creature@status with total_shield:
case shield {
shield:

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.slow.total(
creature: App.KL.Game.Creature
): I32
total_slow = +0#32
let total_slow = +0#32
for slow in creature@status with total_slow:
case slow {
slow:

View File

@ -2,7 +2,7 @@ App.KL.Game.Creature.Status.weaken.total(
creature: App.KL.Game.Creature
): I32
total_weaken = +0#32
let total_weaken = +0#32
for weaken in creature@status with total_weaken:
case weaken {
weaken:

View File

@ -10,15 +10,15 @@ App.KL.Game.Effect.bind<A: Type, B: Type>(
new: case next(result_a.value)(result_a.center, targets, result_a.cast_data, result_a.board) as result_b {
err: App.KL.Game.Effect.Result.err<B>(result_b.message)
new:
center = result_b.center
value = result_b.value
cast_data = result_b.cast_data
map = result_b.board
indicators = Hexagonal.Axial.Map.union!(result_a.indicators, result_b.indicators)
ap_used = result_a.ap_used + result_b.ap_used
cemetery = result_a.cemetery ++ result_b.cemetery
description = App.KL.Game.Effect.bind.description(result_a.description, result_b.description)
player_data = App.KL.Game.Effect.player_data.union(result_a.player_data, result_b.player_data)
let center = result_b.center
let value = result_b.value
let cast_data = result_b.cast_data
let map = result_b.board
let indicators = Hexagonal.Axial.Map.union!(result_a.indicators, result_b.indicators)
let ap_used = result_a.ap_used + result_b.ap_used
let cemetery = result_a.cemetery ++ result_b.cemetery
let description = App.KL.Game.Effect.bind.description(result_a.description, result_b.description)
let player_data = App.KL.Game.Effect.player_data.union(result_a.player_data, result_b.player_data)
App.KL.Game.Effect.Result.new<B>(value, center, cast_data, map, indicators, ap_used, cemetery, description, player_data)
}
}

View File

@ -1,6 +1,6 @@
App.KL.Game.Effect.limit_range(range: I32): App.KL.Game.Effect<Unit>
(center, targets, cast_data, board)
in_range = true
let in_range = true
for target in targets with in_range:
in_range && I32.lte(Hexagonal.Axial.distance(center, target), range)

View File

@ -1,6 +1,6 @@
App.KL.Game.Effect.limit_range_at(range: I32, coord: Hexagonal.Axial): App.KL.Game.Effect<Unit>
(center, targets, cast_data, board)
in_range = true
let in_range = true
for target in targets with in_range:
in_range && I32.lte(Hexagonal.Axial.distance(coord, target), range)

View File

@ -1,7 +1,7 @@
App.KL.Game.Effect.limit_range_vector(range: I32): App.KL.Game.Effect<Unit>
(center, targets, cast_data, board)
direction = targets[0] <> center
start = targets[1] <> direction
let direction = targets[0] <> center
let start = targets[1] <> direction
if I32.gtn(Hexagonal.Axial.distance(center, start), range) then
App.KL.Game.Effect.Result.err<Unit>("out of range.")
else

View File

@ -19,7 +19,7 @@ App.KL.Game.Effect.player_data.union(
some none: some(a_recap.value)
some some: some(a_recap.value ++ b_recap.value)
}
new_data = Pair.new!!(scoreboard, recap)
let new_data = Pair.new!!(scoreboard, recap)
a{id} <- new_data
}
a

View File

@ -38,7 +38,7 @@ type App.KL.Game.Hero.Attributes {
}
App.KL.Game.Hero.Attributes.set(damage: Nat, resistance: Nat, mobility: Nat, range: Nat, utility: Nat, difficulty: Nat): App.KL.Game.Hero.Attributes
max = Nat.min(5)
let max = Nat.min(5)
App.KL.Game.Hero.Attributes.new(
max(damage)
max(resistance)

View File

@ -99,7 +99,7 @@ App.KL.Game.Hero.Octoking.hero.Skills.swap(range_fst: I32, range_snd: I32, ap_co
App.KL.Game.Effect.fail("No primary target was selected")
}
cons:
in_range = true
let in_range = true
for target in targets with in_range:
in_range && I32.lte(Hexagonal.Axial.distance(targets.head, target), range_snd)

View File

@ -55,7 +55,7 @@ App.KL.Game.Moment.create_board.choose_coord(
board: App.KL.Game.Board
): App.KL.Game.Board
position = none :: Maybe<App.KL.Game.Board>
let position = none :: Maybe<App.KL.Game.Board>
for coord:team in coords with position:
case position {
none:

View File

@ -8,7 +8,7 @@
App.KL.Game.Phase.Draft.has_hero(hero_id: U8, team: App.KL.Game.Team, player: Pair<String, App.KL.Game.Player>): Bool
x = player@snd@hero_id
let x = player@snd@hero_id
if App.KL.Game.Team.eql(team, player@snd@team) then
case x {
none: false
@ -19,7 +19,7 @@ App.KL.Game.Phase.Draft.has_hero(hero_id: U8, team: App.KL.Game.Team, player: Pa
// check if player has a coord
App.KL.Game.Phase.Draft.has_coord(coord: Hexagonal.Axial, player: Pair<String, App.KL.Game.Player>): Bool
x = player@snd@init_pos
let x = player@snd@init_pos
case x {
none: false
some: Hexagonal.Axial.eql(x.value, coord)
@ -27,7 +27,7 @@ App.KL.Game.Phase.Draft.has_coord(coord: Hexagonal.Axial, player: Pair<String, A
// get team of a player
App.KL.Game.Phase.Draft.to_team(players: Map<App.KL.Game.Player>, user: String): Maybe<App.KL.Game.Team>
player = players{user}
let player = players{user}
case player {
none: none
some: some(player.value@team)

View File

@ -16,8 +16,8 @@ App.KL.Game.Phase.Draft.tick(
if pair@fst && pair@snd then
log("- to_board")
game = game@phase <- App.KL.Game.Phase.play // Phase -> Game
game = game@board <- App.KL.Game.Phase.Draft.create_board(players, game@blueprint) // App.KL.Game.Phase.Draft.create_board(players)
let game = game@phase <- App.KL.Game.Phase.play // Phase -> Game
let game = game@board <- App.KL.Game.Phase.Draft.create_board(players, game@blueprint) // App.KL.Game.Phase.Draft.create_board(players)
game
else
game

View File

@ -66,7 +66,13 @@ App.KL.Game.Phase.Play.draw.get_players_heroes(players: Map<App.KL.Game.Player>)
App.KL.Game.Phase.Play.draw.get_players_skills(players: Map<App.KL.Game.Player>): List<SkillInfo>
let game_heroes = App.KL.Game.Phase.Play.draw.get_players_heroes(players)
let game_skills = List.flatten!(List.mapped!(game_heroes)!((hero) List.mapped!(Map.to_list!(hero@skills))!((x) {Pair.fst!!(x), {hero,Pair.snd!!(x)}})))
let game_skills = List.sort!((a,b) let as = Pair.snd!!(Pair.snd!!(a)); bs = Pair.snd!!(Pair.snd!!(b)); U64.cmp(as@delay, bs@delay), game_skills)
let game_skills = List.sort!(
(a,b)
let as = Pair.snd!!(Pair.snd!!(a));
let bs = Pair.snd!!(Pair.snd!!(b));
U64.cmp(as@delay, bs@delay),
game_skills
)
game_skills
// return a list with skill info of all players
@ -273,7 +279,7 @@ App.KL.Game.Phase.Play.draw.ap(
): VoxBox
let ap = App.KL.Game.Board.Creature.get.ap(creature)
let max_ap = App.KL.Game.Board.Creature.get.max_ap(creature)
no_cast = App.KL.Game.Phase.Play.draw.ap.bars(x, y, ap, 0, 0, I32.to_u32(max_ap), img)
let no_cast = App.KL.Game.Phase.Play.draw.ap.bars(x, y, ap, 0, 0, I32.to_u32(max_ap), img)
case creature@category {
summon: img
hero:
@ -296,13 +302,13 @@ App.KL.Game.Phase.Play.draw.ap.bars(x: U32 y: U32, blue: I32, red: I32, bar_idx:
if U32.gte(bar_idx, bar_quantity) then
img
else
img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.gray, img)
let img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.gray, img)
App.KL.Game.Phase.Play.draw.ap.bars(x, y, blue, red, bar_idx + 1, bar_quantity, img)
else
img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.red, img)
let img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.red, img)
App.KL.Game.Phase.Play.draw.ap.bars(x, y, blue, red - 1, bar_idx + 1, bar_quantity, img)
else
img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.blue, img)
let img = VoxBox.Draw.image(x + (12 * bar_idx), y, App.KL.Constants.z_index.ap_bar, App.KL.Game.Phase.Play.Ap.Assets.blue, img)
App.KL.Game.Phase.Play.draw.ap.bars(x, y, blue - 1, red, bar_idx + 1, bar_quantity, img)

View File

@ -13,8 +13,8 @@ App.KL.Game.Phase.Play.draw.interface(
App.KL.Game.Phase.Play.draw.interface.casts(user: String, moment: App.KL.Game.Moment, players: Map<App.KL.Game.Player>): DOM
case moment {
execution:
casts = moment.casts
p_cst = moment.previous_casts
let casts = moment.casts
let p_cst = moment.previous_casts
<div style={
"position": "absolute"
@ -430,7 +430,7 @@ App.KL.Game.Phase.Play.draw.interface.bottom.get_skills(
skills: Map<App.KL.Game.Skill>,
max: Nat
): List<Pair<String, App.KL.Game.Skill>>
result = {[] :: List<Pair<String, App.KL.Game.Skill>>, max}
let result = {[] :: List<Pair<String, App.KL.Game.Skill>>, max}
for key: skill in skills with result:
if (max <=? 0) || (skill@name =? "Walk") then
result

View File

@ -101,7 +101,7 @@ App.KL.Game.Phase.Play.when(
App.set_local<App.KL.State>(App.KL.State.Local.game(local@preview <- preview))
}
}default
local =
let local =
Maybe {
get casted_skill = App.KL.Game.Skill.get(local@user, event.code, game)
let skill =

View File

@ -11,7 +11,7 @@ type App.KL.Game.Recap.Episode {
}
App.KL.Game.Recap.show(recap: App.KL.Game.Recap): String
text = ""
let text = ""
for episode in recap with text:
text | "\n" |
"key: " | Char.to_string(episode@skill_key) | "\n" |

View File

@ -2,6 +2,6 @@ App.KL.Game.Tile.effect.get_data(
tile: App.KL.Game.Tile
): Maybe<Pair<Char,String>>
effect = tile@effect
let effect = tile@effect
without effect: none
some(effect@cast_data)

View File

@ -79,7 +79,7 @@ App.KL.Lobby.draw(local: App.KL.Lobby.State.Local, global: App.KL.Global.State):
// </div>
App.KL.Lobby.draw.heroes.hero_menu(hero: Maybe<App.KL.Game.Hero>, skill: Maybe<App.KL.Game.Skill>, tab: String): DOM
descriptions_style =
let descriptions_style =
{
"width": "85%",
"height": "50%"
@ -94,7 +94,7 @@ App.KL.Lobby.draw.heroes.hero_menu(hero: Maybe<App.KL.Game.Hero>, skill: Maybe<A
"border-radius": "5px"
}
skill_show_style =
let skill_show_style =
{
"width": "30%"
"height": "90%"
@ -117,7 +117,7 @@ App.KL.Lobby.draw.heroes.hero_menu(hero: Maybe<App.KL.Game.Hero>, skill: Maybe<A
App.KL.Lobby.draw.heroes.skill(hero: App.KL.Game.Hero): DOM
skills_style =
let skills_style =
{
"width": "30%"
"height": "90%"
@ -127,7 +127,7 @@ App.KL.Lobby.draw.heroes.skill(hero: App.KL.Game.Hero): DOM
"align-items": "center"
}
skill_buttons_style =
let skill_buttons_style =
{
"width": "100%"
"height": "90%"
@ -138,7 +138,7 @@ App.KL.Lobby.draw.heroes.skill(hero: App.KL.Game.Hero): DOM
}
list = []
let list = []
for key:skill in hero@skills with list:
key & list
<div style=skills_style>
@ -151,8 +151,8 @@ App.KL.Lobby.draw.heroes.skill(hero: App.KL.Game.Hero): DOM
App.KL.Lobby.draw.heroes.skill_button(char: String): DOM
id = "S" | char
skill_button_style =
let id = "S" | char
let skill_button_style =
{
"width": "100%"
"height": "90%"
@ -169,7 +169,7 @@ App.KL.Lobby.draw.heroes.skill_button(char: String): DOM
</div>
App.KL.Lobby.draw.heroes.skill_description(skill: Maybe<App.KL.Game.Skill>): DOM
skill_description_style =
let skill_description_style =
{
"width": "30%"
"height": "90%"
@ -313,8 +313,8 @@ App.KL.Lobby.when(
"S":
let skill_key = String.drop(1, event.id)
let skill = Maybe {
get hero = page.hero
get skill = hero@skills{skill_key}
get hero = page.hero
get skill = hero@skills{skill_key}
return skill
}
let new_page = App.KL.Lobby.State.Local.Page.heroes(page.hero, skill, page.tab)

View File

@ -48,13 +48,13 @@ App.Kind.draw_page(stt: App.Kind.State.local): DOM
// Executes the application
App.Kind: App(App.Kind.State)
init =
let init =
App.Store.new!(App.Kind.State.local.new(Device.big_desktop, App.Kind.Page.home, ""), unit)
draw = (state)
let draw = (state)
App.Kind.draw_page(state@local)
when = (event, state)
let when = (event, state)
case event {
init:
open event.info
@ -71,10 +71,10 @@ App.Kind: App(App.Kind.State)
App.set_local!(App.Kind.State.local.new(device, state.page, state.mouse_over))
} default App.pass!
tick = (tick, glob)
let tick = (tick, glob)
glob
post = (time, room, addr, data, glob)
let post = (time, room, addr, data, glob)
glob
// The application

View File

@ -152,13 +152,13 @@ App.Playground.when: App.When<App.Playground.State>
// Executes the application
App.Playground: App(App.Playground.State)
init = App.Store.new<App.Playground.State>(
let init = App.Store.new<App.Playground.State>(
App.Playground.State.local_empty,
unit)
draw = (state) App.playground.body(state@local)
when = App.Playground.when
tick = (tick, glob) glob
post = (time, room, addr, data, glob) glob
let draw = (state) App.playground.body(state@local)
let when = App.Playground.when
let tick = (tick, glob) glob
let post = (time, room, addr, data, glob) glob
App.new!(init, draw, when, tick, post)

View File

@ -38,8 +38,8 @@ Ether.encode(length : Nat, coder : List<Ether.ABI.Type>) : Pair<List<String>, Li
Ether.encode.read(enconding : Pair<List<String>, List<String>>) : String
let {static, dynamic} = enconding
static = List.map!!((x) "0x" | x, static)
dynamic = List.map!!((x) "0x" | x, dynamic)
let static = List.map!!((x) "0x" | x, static)
let dynamic = List.map!!((x) "0x" | x, dynamic)
String.join("", static) | String.join("", dynamic)

View File

@ -52,10 +52,10 @@ Ether.ABI.methodData(method : Ether.Encode.ABI.Method) : String
open coder
if coder.snd then
let dataLoc = (encodeSize*32) + String.length(dataBlock)
headBlock = headBlock | String.pad_left(64, '0', Nat.hex.encode(dataLoc))
dataBlock = dataBlock | coder.fst
let headBlock = headBlock | String.pad_left(64, '0', Nat.hex.encode(dataLoc))
let dataBlock = dataBlock | coder.fst
{dataBlock, headBlock}
else
dataBlock = dataBlock | coder.fst
let dataBlock = dataBlock | coder.fst
{dataBlock, headBlock}
methodHash | Pair.snd!!(hexs) | Pair.fst!!(hexs)

View File

@ -19,12 +19,12 @@ Ether.Address.Checksum.generate(encoding : List<Pair<Bits, Pair<String, String>>
let {char, char1} = chars
let str = Ether.Address.Checksum.generate(encoding.tail)
str = if Bits.lte(Nat.to_bits(8), Bits.and(Nat.to_bits(15), hash)) then
let str = if Bits.lte(Nat.to_bits(8), Bits.and(Nat.to_bits(15), hash)) then
String.to_upper(char1) | str
else
String.to_lower(char1) | str
str = if Bits.lte(Nat.to_bits(8), Bits.shift_right(4, hash)) then
let str = if Bits.lte(Nat.to_bits(8), Bits.shift_right(4, hash)) then
String.to_upper(char) | str
else
String.to_lower(char) | str

View File

@ -14,13 +14,13 @@ Ether.Base.X64.decode(blocks : List<U16>) : Bits
let block_bits = Bits.e
for j in acc with block_bits :
def r = BBT.lookup!!(U16.cmp, j, Ether.Base.X64.table.decode) <> 0
block_bits = Bits.concat(Nat.to_bits(r), block_bits)
let block_bits = Bits.concat(Nat.to_bits(r), block_bits)
// log(U16.show(j) | " " | Bits.show(Bits.e))
block_bits
def size = Ether.Bits.get_bytes_size(block_bits)
def dif = List.length!(i) - List.length!(acc)
//log(Bits.show(block_bits))
bits = Bits.concat(bits, Bits.drop(dif*(2*size), block_bits))
let bits = Bits.concat(bits, Bits.drop(dif*(2*size), block_bits))
// def r = BBT.lookup!!(U16.cmp, i, Ether.Base.X64.table.decode) <> 0
bits

View File

@ -3,7 +3,7 @@ Ether.Base.X64.translate(code : Bits) : List<U16>
let list = []
for i in blocks with list :
def index = Bits.to_nat(Bits.reverse(i))
list = List.cons!(Ether.Base.X64.table[index] <> 0#16, list)
let list = List.cons!(Ether.Base.X64.table[index] <> 0#16, list)
list
list
@ -13,8 +13,8 @@ Ether.Base.X64.encode(code : Bits) : List<U16>
for i in blocks with list :
def size = Ether.Bits.get_bytes_size(i)
let pad = (3-size)
i = Bits.concat(i, Bits.repeat(pad*2, false))
list = list ++ Ether.Base.X64.translate(i) ++ List.repeat!(pad, 61)
let i = Bits.concat(i, Bits.repeat(pad*2, false))
let list = list ++ Ether.Base.X64.translate(i) ++ List.repeat!(pad, 61)
list
list

View File

@ -3,8 +3,8 @@ Ether.Units.decode(encoding : Pair<List<Nat>, List<Nat>>, ether_ref : Nat) : May
if (Nat.ltn(ether_ref, List.length!(frac))) then
none
else
int = Nat.from_base(10, int)
frac = Nat.from_base(10, frac)
let int = Nat.from_base(10, int)
let frac = Nat.from_base(10, frac)
let dec = (int * Nat.pow(10, ether_ref))
some(dec +
(frac * Nat.pow(10, Nat.log(10, dec) - (Nat.log(10, frac)) + 1)))

View File

@ -1,13 +1,13 @@
// A bubble sort function, showcasing many Pythonish syntaxes
Example.bubble_sort(list: List<Nat>): List<Nat>
length = List.length!(list)
let length = List.length!(list)
for i from 0 to length - 1 with list:
for j from 0 to (length - i) - 1 with list:
val_a = list[j + 0] <> 0
val_b = list[j + 1] <> 0
let val_a = list[j + 0] <> 0
let val_b = list[j + 1] <> 0
if val_a >? val_b then
list = list[j + 0] <- val_b
list = list[j + 1] <- val_a
let list = list[j + 0] <- val_b
let list = list[j + 1] <- val_a
list
else
list
@ -15,6 +15,6 @@ Example.bubble_sort(list: List<Nat>): List<Nat>
list
Example.bubble_sort.test: String
list = [8, 1, 7, 6, 4, 9, 5, 2, 3]
sort = Example.bubble_sort(list)
let list = [8, 1, 7, 6, 4, 9, 5, 2, 3]
let sort = Example.bubble_sort(list)
List.show!(Nat.show, sort)

View File

@ -1,24 +1,24 @@
// Many container-related syntax sugars
Example.containers.pair: Nat
pair = {1,2} // Pair.new!!(1, 2)
{a,b} = pair // case pair { new: a = pair.fst; b = pair.snd; ... }
let pair = {1,2} // Pair.new!!(1, 2)
let {a,b} = pair // case pair { new: a = pair.fst; b = pair.snd; ... }
a + b
Example.containers.list: Nat
list = [1, 2, 3, 4] // List.cons!(1, List.cons!(2, ...))
list = list[1] <- 200 // List.set!(1, 200, list)
val0 = list[1] <> 0 // Maybe.default!(List.get!(1,list), 0)
val1 = list[2] <> 0 // Maybe.default!(List.get!(2,list), 0)
let list = [1, 2, 3, 4] // List.cons!(1, List.cons!(2, ...))
let list = list[1] <- 200 // List.set!(1, 200, list)
let val0 = list[1] <> 0 // Maybe.default!(List.get!(1,list), 0)
let val1 = list[2] <> 0 // Maybe.default!(List.get!(2,list), 0)
val0 + val1
Example.containers.map: Nat
key = "toe"
map = {"tic": 1, "tac": 2, key: 3} // Map.from_list!([{"tic",1}, ...])
map = map{"tic"} <- 100 // Map.set!("tic", 100, map)
map = map{"tac"} <- 200 // Map.set!("tac", 200, map)
map = map{ key } <- 300 // Map.set!(key, 300, map)
val0 = map{"tic"} <> 0 // Maybe.default!(Map.get!("tic",map), 0)
val1 = map{"tac"} <> 0 // Maybe.default!(Map.get!("tac",map), 0)
val2 = map{ key } <> 0 // Maybe.default!(Map.get!(key, map), 0)
let key = "toe"
let map = {"tic": 1, "tac": 2, key: 3} // Map.from_list!([{"tic",1}, ...])
let map = map{"tic"} <- 100 // Map.set!("tic", 100, map)
let map = map{"tac"} <- 200 // Map.set!("tac", 200, map)
let map = map{ key } <- 300 // Map.set!(key, 300, map)
let val0 = map{"tic"} <> 0 // Maybe.default!(Map.get!("tic",map), 0)
let val1 = map{"tac"} <> 0 // Maybe.default!(Map.get!("tac",map), 0)
let val2 = map{ key } <> 0 // Maybe.default!(Map.get!(key, map), 0)
val0 + val1 + val2

View File

@ -4,7 +4,7 @@ Hexagonal.Axial.circular(
distance: I32
): List<Hexagonal.Axial>
range = Hexagonal.Axial.range(coord, distance)
let range = Hexagonal.Axial.range(coord, distance)
List.filter!((x)not(Hexagonal.Axial.eql(coord, x)), range)

View File

@ -5,9 +5,9 @@ Hexagonal.Axial.clamp(
target: Hexagonal.Axial
): Hexagonal.Axial
f = I32.to_f64
distance = Hexagonal.Axial.distance(center, target)
distance_64 = f(distance)
range_64 = f(range)
let f = I32.to_f64
let distance = Hexagonal.Axial.distance(center, target)
let distance_64 = f(distance)
let range_64 = f(range)
Hexagonal.Axial.lerp(range_64 / distance_64, center, target)

View File

@ -3,5 +3,5 @@ Hexagonal.Axial.clock_rotation(
start: Hexagonal.Axial
): List<Hexagonal.Axial>
coord = Hexagonal.Axial.to_cubic(start)
let coord = Hexagonal.Axial.to_cubic(start)
List.map!!(Hexagonal.Cubic.to_axial, Hexagonal.Cubic.clock_rotation(coord))

View File

@ -4,5 +4,5 @@ Hexagonal.Axial.counter_clock_rotation(
start: Hexagonal.Axial
): List<Hexagonal.Axial>
coord = Hexagonal.Axial.to_cubic(start)
let coord = Hexagonal.Axial.to_cubic(start)
List.map!!(Hexagonal.Cubic.to_axial, Hexagonal.Cubic.counter_clock_rotation(coord))

View File

@ -4,6 +4,6 @@ Hexagonal.Axial.distance(
snd_coord: Hexagonal.Axial
): I32
convert_fst = Hexagonal.Axial.to_cubic(fst_coord)
convert_snd = Hexagonal.Axial.to_cubic(snd_coord)
let convert_fst = Hexagonal.Axial.to_cubic(fst_coord)
let convert_snd = Hexagonal.Axial.to_cubic(snd_coord)
Hexagonal.Cubic.distance(convert_fst, convert_snd)

View File

@ -5,11 +5,11 @@ Hexagonal.Axial.from_nat(
n: Nat
): Hexagonal.Axial
n_converted = Nat.to_u32(n)
coord_i = n_converted / 1000 //U32
coord_i = U32.to_i32(coord_i)
coord_i = coord_i - 100 // I32
coord_j = U32.mod(n_converted, 1000) // U32
coord_j = U32.to_i32(coord_j)
coord_j = coord_j - 100 // I32
let n_converted = Nat.to_u32(n)
let coord_i = n_converted / 1000 //U32
let coord_i = U32.to_i32(coord_i)
let coord_i = coord_i - 100 // I32
let coord_j = U32.mod(n_converted, 1000) // U32
let coord_j = U32.to_i32(coord_j)
let coord_j = coord_j - 100 // I32
Hexagonal.Axial.new(coord_i, coord_j)

View File

@ -3,11 +3,11 @@ Hexagonal.Axial.inside(
coord: Hexagonal.Axial,
region_size: I32
): Bool
coord = Hexagonal.Axial.to_cubic(coord)
let coord = Hexagonal.Axial.to_cubic(coord)
open coord
x = I32.abs(coord.x)
y = I32.abs(coord.y)
z = I32.abs(coord.z)
greater = I32.max(x, I32.max(y, z))
let x = I32.abs(coord.x)
let y = I32.abs(coord.y)
let z = I32.abs(coord.z)
let greater = I32.max(x, I32.max(y, z))
I32.lte(greater, region_size)

View File

@ -5,13 +5,13 @@ Hexagonal.Axial.line_by_direction(
origin: Hexagonal.Axial
): List<Hexagonal.Axial>
coords = []
let coords = []
let diff = Hexagonal.Axial.sub(origin, line_start)
for i from 0 to I32.to_nat(size) with coords:
case coords {
nil: [origin]
cons:
coord = Hexagonal.Axial.add(coords.head, diff)
let coord = Hexagonal.Axial.add(coords.head, diff)
coord & coords
}
coords

View File

@ -4,13 +4,13 @@ Hexagonal.Axial.minimum(
goal: Hexagonal.Axial
): Maybe(Hexagonal.Axial)
neighborhood = Hexagonal.Axial.moore(origin)
sort = ((x, y)
let neighborhood = Hexagonal.Axial.moore(origin)
let sort = ((x, y)
case y {
none:
some(x)
some:
shorter = Hexagonal.Axial.shorter(goal, x, y.value)
let shorter = Hexagonal.Axial.shorter(goal, x, y.value)
if shorter then
some(x)
else

View File

@ -4,8 +4,8 @@ Hexagonal.Axial.moore(
): List<Hexagonal.Axial>
open coord
U32_i = ((i) Int.to_i32(Int.sub(Int.from_nat(U32.to_nat(i)), +1))) :: U32 -> I32
result = []
let U32_i = ((i) Int.to_i32(Int.sub(Int.from_nat(U32.to_nat(i)), +1))) :: U32 -> I32
let result = []
for x : U32 from 0 to 3 with result:
for y : U32 from 0 to 3 with result:
if (U32.eql(x, y)) then

View File

@ -2,15 +2,15 @@ Hexagonal.Axial.neighbour(
coord: Hexagonal.Axial
): List<Hexagonal.Axial>
i = coord@i
j = coord@j
let i = coord@i
let j = coord@j
right = Hexagonal.Axial.new(i + 1, j )
top_right = Hexagonal.Axial.new(i + 1, j - 1)
top_left = Hexagonal.Axial.new(i , j - 1)
left = Hexagonal.Axial.new(i - 1, j )
bottom_left = Hexagonal.Axial.new(i - 1, j + 1)
bottom_right= Hexagonal.Axial.new(i , j + 1)
let right = Hexagonal.Axial.new(i + 1, j )
let top_right = Hexagonal.Axial.new(i + 1, j - 1)
let top_left = Hexagonal.Axial.new(i , j - 1)
let left = Hexagonal.Axial.new(i - 1, j )
let bottom_left = Hexagonal.Axial.new(i - 1, j + 1)
let bottom_right= Hexagonal.Axial.new(i , j + 1)
[right, top_right, top_left, left, bottom_left, bottom_right]

View File

@ -3,7 +3,7 @@ Hexagonal.Axial.path(
goal: Hexagonal.Axial
): Maybe<List<Hexagonal.Axial>>
path_min = Hexagonal.Axial.minimum(coord, goal)
let path_min = Hexagonal.Axial.minimum(coord, goal)
case path_min {
none:
none
@ -11,6 +11,6 @@ Hexagonal.Axial.path(
if (Hexagonal.Axial.eql(path_min.value, goal)) then
some([path_min.value])
else
ls = Hexagonal.Axial.path(path_min.value, goal)
let ls = Hexagonal.Axial.path(path_min.value, goal)
Maybe.extract!(ls, Maybe<List<Hexagonal.Axial>>, none, (a) some(path_min.value & a))
}

View File

@ -4,5 +4,5 @@ Hexagonal.Axial.range(
distance: I32
): List<Hexagonal.Axial>
center = Hexagonal.Axial.to_cubic(coord)
let center = Hexagonal.Axial.to_cubic(coord)
List.map!!(Hexagonal.Cubic.to_axial, Hexagonal.Cubic.range(center, distance))

View File

@ -3,6 +3,6 @@ Hexagonal.Axial.rotate_left(
axis: Hexagonal.Axial
): Hexagonal.Axial
a = Hexagonal.Axial.to_cubic(start)
b = Hexagonal.Axial.to_cubic(axis)
let a = Hexagonal.Axial.to_cubic(start)
let b = Hexagonal.Axial.to_cubic(axis)
Hexagonal.Cubic.to_axial(Hexagonal.Cubic.rotate_left(a,b))

View File

@ -3,6 +3,6 @@ Hexagonal.Axial.rotate_right(
axis: Hexagonal.Axial
): Hexagonal.Axial
a = Hexagonal.Axial.to_cubic(start)
b = Hexagonal.Axial.to_cubic(axis)
let a = Hexagonal.Axial.to_cubic(start)
let b = Hexagonal.Axial.to_cubic(axis)
Hexagonal.Cubic.to_axial(Hexagonal.Cubic.rotate_right(a,b))

View File

@ -4,31 +4,31 @@ Hexagonal.Axial.round(
axial_y: F64
): Hexagonal.Axial
i = F64.to_i32
axial_z = (0.0 - axial_x) - axial_y
let i = F64.to_i32
let axial_z = (0.0 - axial_x) - axial_y
round_x = Hexagonal.Axial.aux.round_F64(axial_x)
round_y = Hexagonal.Axial.aux.round_F64(axial_y)
round_z = Hexagonal.Axial.aux.round_F64(axial_z)
let round_x = Hexagonal.Axial.aux.round_F64(axial_x)
let round_y = Hexagonal.Axial.aux.round_F64(axial_y)
let round_z = Hexagonal.Axial.aux.round_F64(axial_z)
diff_x = Hexagonal.Axial.aux.abs_diff(axial_x, round_x)
diff_y = Hexagonal.Axial.aux.abs_diff(axial_y, round_y)
diff_z = Hexagonal.Axial.aux.abs_diff(axial_z, round_z)
let diff_x = Hexagonal.Axial.aux.abs_diff(axial_x, round_x)
let diff_y = Hexagonal.Axial.aux.abs_diff(axial_y, round_y)
let diff_z = Hexagonal.Axial.aux.abs_diff(axial_z, round_z)
case F64.gtn(diff_x, diff_z) {
true:
case F64.gtn(diff_y, diff_x) {
true:
new_y = (0.0 - round_x) - round_z
let new_y = (0.0 - round_x) - round_z
Hexagonal.Axial.new(i(round_x), i(new_y))
false:
new_x = (0.0 - round_y) - round_z
let new_x = (0.0 - round_y) - round_z
Hexagonal.Axial.new(i(new_x), i(round_y))
}
false:
case F64.gtn(diff_y, diff_z) {
true:
new_y = (0.0 - round_x) - round_z
let new_y = (0.0 - round_x) - round_z
Hexagonal.Axial.new(i(round_x), i(new_y))
false:
Hexagonal.Axial.new(i(round_x), i(round_y))
@ -39,10 +39,10 @@ Hexagonal.Axial.round(
// TODO: Rheidner
// Rounds a F64 number to the nearest integer
Hexagonal.Axial.aux.round_F64(n: F64): F64
half = 0.5
big_number = 1000.0 // TODO while F64.gtn, cmp and ltn is broken
n = n + big_number
result = Hexagonal.Axial.aux.floor(n + half)
let half = 0.5
let big_number = 1000.0 // TODO while F64.gtn, cmp and ltn is broken
let n = n + big_number
let result = Hexagonal.Axial.aux.floor(n + half)
result - big_number
// TODO

View File

@ -4,7 +4,7 @@ Hexagonal.Axial.semi_circle(
goal: Hexagonal.Axial
): List<Hexagonal.Axial>
new = Hexagonal.Axial.new
let new = Hexagonal.Axial.new
open origin as a
open goal as b
let coords =

View File

@ -8,12 +8,12 @@ Hexagonal.Axial.shorter(
open goal
open a
open b
a_dis0 = a.i - goal.i // I32
a_dis1 = a.j - goal.j // I32
b_dis0 = b.i - goal.i // I32
b_dis1 = b.j - goal.j // I32
ab_dis0_comp = I32.ltn(I32.abs(a_dis0), I32.abs(b_dis0)) // ai < bi
ab_dis0_min = I32.eql(I32.abs(a_dis0), I32.abs(b_dis0)) // ai = bi
ab_dis1_comp = I32.ltn(I32.abs(a_dis1), I32.abs(b_dis1)) // aj < bj
diff = ab_dis0_min && ab_dis1_comp
let a_dis0 = a.i - goal.i // I32
let a_dis1 = a.j - goal.j // I32
let b_dis0 = b.i - goal.i // I32
let b_dis1 = b.j - goal.j // I32
let ab_dis0_comp = I32.ltn(I32.abs(a_dis0), I32.abs(b_dis0)) // ai < bi
let ab_dis0_min = I32.eql(I32.abs(a_dis0), I32.abs(b_dis0)) // ai = bi
let ab_dis1_comp = I32.ltn(I32.abs(a_dis1), I32.abs(b_dis1)) // aj < bj
let diff = ab_dis0_min && ab_dis1_comp
Bool.or(ab_dis0_comp, diff)

View File

@ -3,5 +3,5 @@ Hexagonal.Axial.to_bits(
coord : Hexagonal.Axial
): Bits
unique_nat = Hexagonal.Axial.to_nat(coord)
let unique_nat = Hexagonal.Axial.to_nat(coord)
Nat.to_bits(unique_nat)

View File

@ -4,7 +4,7 @@ Hexagonal.Axial.to_cubic(
): Hexagonal.Cubic
open coord
x = coord.i
z = coord.j
y = (I32.neg(x) - z)
let x = coord.i
let z = coord.j
let y = (I32.neg(x) - z)
Hexagonal.Cubic.new(x, y, z)

View File

@ -4,10 +4,10 @@ Hexagonal.Axial.to_nat(
): Nat
open coord
i = coord.i + 100 // I32
i = i * 1000
i = I32.to_u32(i)
j = coord.j + 100
j = I32.to_u32(j)
sum = i + j //U32
let i = coord.i + 100 // I32
let i = i * 1000
let i = I32.to_u32(i)
let j = coord.j + 100
let j = I32.to_u32(j)
let sum = i + j //U32
U32.to_nat(sum)

View File

@ -7,22 +7,22 @@ Hexagonal.Axial.to_screen_xy(
): Pair<U32,U32> // TODO add alias
open coord
i = coord.i
j = coord.j
let i = coord.i
let j = coord.j
i = I32.to_f64(i)
j = I32.to_f64(j)
int_rad = I32.to_f64(radius)
hlf = F64.div(int_rad, 2.0#64)
int_screen_center_x = I32.to_f64(center_x)
int_screen_center_y = I32.to_f64(center_y)
let i = I32.to_f64(i)
let j = I32.to_f64(j)
let int_rad = I32.to_f64(radius)
let hlf = F64.div(int_rad, 2.0#64)
let int_screen_center_x = I32.to_f64(center_x)
let int_screen_center_y = I32.to_f64(center_y)
cx = int_screen_center_x + j * int_rad // screen_center + j * rad
cx = cx + i * int_rad * 2 // screen_center + j * rad + i * 2rad
cy = I32.to_f64(F64.to_i32(hlf * 3)) // fix rounding of odd radius
cy = int_screen_center_y + j * cy // screen_center + j * (3rad/2)
let cx = int_screen_center_x + j * int_rad // screen_center + j * rad
let cx = cx + i * int_rad * 2 // screen_center + j * rad + i * 2rad
let cy = I32.to_f64(F64.to_i32(hlf * 3)) // fix rounding of odd radius
let cy = int_screen_center_y + j * cy // screen_center + j * (3rad/2)
cx = F64.to_u32(cx)
y = cy + 0.5 // to round correctly
cy = F64.to_u32(cy)
let cx = F64.to_u32(cx)
let y = cy + 0.5 // to round correctly
let cy = F64.to_u32(cy)
{cx, cy}

View File

@ -6,7 +6,7 @@ Hexagonal.Cubic.add(
open coord_a
open coord_b
x = coord_a.x + coord_b.x // I32
y = coord_a.y + coord_b.y // I32
z = coord_a.z + coord_b.z // I32
let x = coord_a.x + coord_b.x // I32
let y = coord_a.y + coord_b.y // I32
let z = coord_a.z + coord_b.z // I32
Hexagonal.Cubic.new(x, y, z)

View File

@ -5,26 +5,26 @@ Hexagonal.Cubic.clock_rotation(
//https://www.redblobgames.com/grids/hexagons/#rotation
x = start@x
y = start@y
z = start@z
let x = start@x
let y = start@y
let z = start@z
neg_x = x * -1
neg_y = y * -1
neg_z = z * -1
let neg_x = x * -1
let neg_y = y * -1
let neg_z = z * -1
start_coord = Hexagonal.Cubic.new(x , y , z )
sixty_degrees = Hexagonal.Cubic.new(neg_z, neg_x, neg_y)
one_hundred_twenty_degrees = Hexagonal.Cubic.new(y , z , x )
one_hundred_eighty_degrees = Hexagonal.Cubic.new(neg_x, neg_y, neg_z)
two_hundred_fourty_degrees = Hexagonal.Cubic.new(z , x , y )
three_hundred_degrees = Hexagonal.Cubic.new(neg_y, neg_z, neg_x)
let start_coord = Hexagonal.Cubic.new(x , y , z )
let sixty_degrees = Hexagonal.Cubic.new(neg_z, neg_x, neg_y)
let one_hundred_twenty_degrees = Hexagonal.Cubic.new(y , z , x )
let one_hundred_eighty_degrees = Hexagonal.Cubic.new(neg_x, neg_y, neg_z)
let two_hundred_fourty_degrees = Hexagonal.Cubic.new(z , x , y )
let three_hundred_degrees = Hexagonal.Cubic.new(neg_y, neg_z, neg_x)
fst = start_coord
snd = sixty_degrees
third = one_hundred_twenty_degrees
fourth = one_hundred_eighty_degrees
fifth = two_hundred_fourty_degrees
sixth = three_hundred_degrees
let fst = start_coord
let snd = sixty_degrees
let third = one_hundred_twenty_degrees
let fourth = one_hundred_eighty_degrees
let fifth = two_hundred_fourty_degrees
let sixth = three_hundred_degrees
[fst, snd, third, fourth, fifth, sixth]

View File

@ -6,26 +6,26 @@ Hexagonal.Cubic.counter_clock_rotation(
//https://www.redblobgames.com/grids/hexagons/#rotation
x = start@x
y = start@y
z = start@z
let x = start@x
let y = start@y
let z = start@z
neg_x = x * -1
neg_y = y * -1
neg_z = z * -1
let neg_x = x * -1
let neg_y = y * -1
let neg_z = z * -1
start_coord = Hexagonal.Cubic.new(x , y , z )
sixty_degrees = Hexagonal.Cubic.new(neg_y, neg_z, neg_x)
one_hundred_twenty_degrees = Hexagonal.Cubic.new(z , x , y )
one_hundred_eighty_degrees = Hexagonal.Cubic.new(neg_x, neg_y, neg_z)
two_hundred_fourty_degrees = Hexagonal.Cubic.new(y , z , x )
three_hundred_degrees = Hexagonal.Cubic.new(neg_z, neg_x, neg_y)
let start_coord = Hexagonal.Cubic.new(x , y , z )
let sixty_degrees = Hexagonal.Cubic.new(neg_y, neg_z, neg_x)
let one_hundred_twenty_degrees = Hexagonal.Cubic.new(z , x , y )
let one_hundred_eighty_degrees = Hexagonal.Cubic.new(neg_x, neg_y, neg_z)
let two_hundred_fourty_degrees = Hexagonal.Cubic.new(y , z , x )
let three_hundred_degrees = Hexagonal.Cubic.new(neg_z, neg_x, neg_y)
fst = start_coord
snd = sixty_degrees
third = one_hundred_twenty_degrees
fourth = one_hundred_eighty_degrees
fifth = two_hundred_fourty_degrees
sixth = three_hundred_degrees
let fst = start_coord
let snd = sixty_degrees
let third = one_hundred_twenty_degrees
let fourth = one_hundred_eighty_degrees
let fifth = two_hundred_fourty_degrees
let sixth = three_hundred_degrees
[fst, snd, third, fourth, fifth, sixth]

View File

@ -6,7 +6,7 @@ Hexagonal.Cubic.distance(
open coord_a as axis_a
open coord_b as axis_b
subx = I32.sub(axis_a.x, axis_b.x)
suby = I32.sub(axis_a.y, axis_b.y)
subz = I32.sub(axis_a.z, axis_b.z)
let subx = I32.sub(axis_a.x, axis_b.x)
let suby = I32.sub(axis_a.y, axis_b.y)
let subz = I32.sub(axis_a.z, axis_b.z)
I32.max(I32.max(I32.abs(subx), I32.abs(suby)), I32.abs(subz))

View File

@ -4,17 +4,17 @@ Hexagonal.Cubic.neighbors(
coord: Hexagonal.Cubic
): List<Hexagonal.Cubic>
x = coord@x
y = coord@y
z = coord@z
let x = coord@x
let y = coord@y
let z = coord@z
//https://www.redblobgames.com/grids/hexagons/#neighbors
right = Hexagonal.Cubic.new(x + 1, y - 1, z )
top_right = Hexagonal.Cubic.new(x + 1, y , z - 1)
top_left = Hexagonal.Cubic.new(x , y + 1, z - 1)
left = Hexagonal.Cubic.new(x - 1, y + 1, z )
bottom_left = Hexagonal.Cubic.new(x - 1, y , z + 1)
bottom_right= Hexagonal.Cubic.new(x , y - 1, z + 1)
let right = Hexagonal.Cubic.new(x + 1, y - 1, z )
let top_right = Hexagonal.Cubic.new(x + 1, y , z - 1)
let top_left = Hexagonal.Cubic.new(x , y + 1, z - 1)
let left = Hexagonal.Cubic.new(x - 1, y + 1, z )
let bottom_left = Hexagonal.Cubic.new(x - 1, y , z + 1)
let bottom_right= Hexagonal.Cubic.new(x , y - 1, z + 1)
[right, top_right, top_left, left, bottom_left, bottom_right]

View File

@ -4,21 +4,21 @@ Hexagonal.Cubic.range(
distance: I32
): List<Hexagonal.Cubic>
distance_32 = I32.to_u32(distance)
double_distance = U32.add(U32.mul(distance_32, 2), 1) // distance * 2 + 1
result = []
let distance_32 = I32.to_u32(distance)
let double_distance = U32.add(U32.mul(distance_32, 2), 1) // distance * 2 + 1
let result = []
for actual_distance : U32 from 0 to double_distance with result:
negative_distance = I32.neg(distance)
positive_distance = distance
actual_distance = U32.to_i32(actual_distance)
x = I32.sub(actual_distance, positive_distance)
max = I32.max(negative_distance, I32.add(I32.neg(x), negative_distance)) //-1 1-1 0
min = I32.min(positive_distance, I32.add(I32.neg(x), positive_distance)) //1 2 1
distance_between_max_min = U32.add(1, I32.to_u32(I32.abs(I32.sub(max, min)))) // 1
let negative_distance = I32.neg(distance)
let positive_distance = distance
let actual_distance = U32.to_i32(actual_distance)
let x = I32.sub(actual_distance, positive_distance)
let max = I32.max(negative_distance, I32.add(I32.neg(x), negative_distance)) //-1 1-1 0
let min = I32.min(positive_distance, I32.add(I32.neg(x), positive_distance)) //1 2 1
let distance_between_max_min = U32.add(1, I32.to_u32(I32.abs(I32.sub(max, min)))) // 1
for range : U32 from 0 to distance_between_max_min with result:
y = I32.add(U32.to_i32(range), max)
z = I32.sub(I32.neg(x), y)
new_coord = Hexagonal.Cubic.add(coord, Hexagonal.Cubic.new(x,y,z))
let y = I32.add(U32.to_i32(range), max)
let z = I32.sub(I32.neg(x), y)
let new_coord = Hexagonal.Cubic.add(coord, Hexagonal.Cubic.new(x,y,z))
List.cons!(new_coord, result)
result
result

View File

@ -6,16 +6,16 @@ Hexagonal.Cubic.rotate_left(
open a
open b
x = a.x - b.x
y = a.y - b.y
z = a.z - b.z
let x = a.x - b.x
let y = a.y - b.y
let z = a.z - b.z
x_new = y * -1
y_new = z * -1
z_new = x * -1
let x_new = y * -1
let y_new = z * -1
let z_new = x * -1
x = b.x + x_new
y = b.y + y_new
z = b.z + z_new
let x = b.x + x_new
let y = b.y + y_new
let z = b.z + z_new
Hexagonal.Cubic.new(x, y, z)

View File

@ -6,16 +6,16 @@ Hexagonal.Cubic.rotate_right(
open a
open b
x = a.x - b.x
y = a.y - b.y
z = a.z - b.z
let x = a.x - b.x
let y = a.y - b.y
let z = a.z - b.z
x_new = z * -1
y_new = x * -1
z_new = y * -1
let x_new = z * -1
let y_new = x * -1
let z_new = y * -1
x = b.x + x_new
y = b.y + y_new
z = b.z + z_new
let x = b.x + x_new
let y = b.y + y_new
let z = b.z + z_new
Hexagonal.Cubic.new(x, y, z)

View File

@ -4,6 +4,6 @@ Hexagonal.Cubic.to_axial(
): Hexagonal.Axial
open coord
i = coord.x
j = coord.z
let i = coord.x
let j = coord.z
Hexagonal.Axial.new(i, j)

View File

@ -3,7 +3,7 @@ Int.abs(a: Int): Nat
case neg {
false: open a
a.pos
true: a = Int.neg(a)
true: let a = Int.neg(a)
open a
a.pos
}

View File

@ -22,11 +22,11 @@ Kind.Parser.term: Parser(Kind.Term)
Kind.Parser.getforin.with((x) Kind.Parser.term)
Kind.Parser.let.abort((x) Kind.Parser.term)
Kind.Parser.let((x) Kind.Parser.term)
Kind.Parser.let.omit((x) Kind.Parser.term)
// Kind.Parser.let.omit((x) Kind.Parser.term)
Kind.Parser.getwhile((x) Kind.Parser.term)
Kind.Parser.getwhile.with((x) Kind.Parser.term)
Kind.Parser.get((x) Kind.Parser.term)
Kind.Parser.get.omit((x) Kind.Parser.term)
// Kind.Parser.get.omit((x) Kind.Parser.term)
Kind.Parser.def((x) Kind.Parser.term)
Kind.Parser.lens.let((x) Kind.Parser.term)
Kind.Parser.use.abort((x) Kind.Parser.term)

View File

@ -1,2 +1,2 @@
Kind.version: String
"1.0.97"
"1.0.105"

View File

@ -3,6 +3,6 @@ Nat.lte.zero_right(n: Nat, Hyp: Nat.lte(n, 0) == true): n == 0
zero:
refl
succ:
contra = Bool.false_neq_true(Hyp)
let contra = Bool.false_neq_true(Hyp)
Empty.absurd!(contra)
}!

View File

@ -3,11 +3,11 @@
Nat.to_axial(
key: Nat
): Hexagonal.Axial
key_converted = Nat.to_u32(key)
coord_i = key_converted / 1000 //U32
coord_i = U32.to_i32(coord_i)
coord_i = coord_i - 100 // I32
coord_j = U32.mod(key_converted, 1000) // U32
coord_j = U32.to_i32(coord_j)
coord_j = coord_j - 100 // I32
let key_converted = Nat.to_u32(key)
let coord_i = key_converted / 1000 //U32
let coord_i = U32.to_i32(coord_i)
let coord_i = coord_i - 100 // I32
let coord_j = U32.mod(key_converted, 1000) // U32
let coord_j = U32.to_i32(coord_j)
let coord_j = coord_j - 100 // I32
Hexagonal.Axial.new(coord_i, coord_j)

View File

@ -47,7 +47,7 @@ Nat.randoms(len: Nat, seed: Nat, max: Nat): List<Nat>
zero:
[]
succ:
new_seed = Nat.random(seed)
let new_seed = Nat.random(seed)
(new_seed % max) & Nat.randoms(len.pred, new_seed, max)
}

View File

@ -54,11 +54,11 @@ User.caotic.ABI.methodData(method : User.caotic.Encode.ABI.Method) : _
open coder
if coder.snd then
let dataLoc = (encodeSize*32) + String.length(dataBlock)
headBlock = headBlock | String.pad_left(64, '0', Nat.hex.encode(dataLoc))
dataBlock = dataBlock | coder.fst
let headBlock = headBlock | String.pad_left(64, '0', Nat.hex.encode(dataLoc))
let dataBlock = dataBlock | coder.fst
{dataBlock, headBlock}
else
dataBlock = dataBlock | coder.fst
let dataBlock = dataBlock | coder.fst
{dataBlock, headBlock}
methodHash | Pair.snd!!(hexs) | Pair.fst!!(hexs)
@ -134,8 +134,8 @@ User.caotic.encode(length : Nat, coder : List<Method.Type>) : Pair<List<String>,
User.caotic.encode.read(enconding : Pair<List<String>, List<String>>) : String
let {static, dynamic} = enconding
static = List.map!!((x) "0x" | x, static)
dynamic = List.map!!((x) "0x" | x, dynamic)
let static = List.map!!((x) "0x" | x, static)
let dynamic = List.map!!((x) "0x" | x, dynamic)
String.join("", static) | String.join("", dynamic)
User.caotic.ABI.encode : _

Some files were not shown because too many files have changed in this diff Show More