Last active
June 4, 2019 23:04
-
-
Save MaisaMilena/c507178e97caa20c5a73d7a45def5fad to your computer and use it in GitHub Desktop.
Playing with pattern match in FormalityCore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def WHITE : 0 | |
def BLACK : 1 | |
def BOARD : 2 | |
// Flips a value to "true" (1) or "false" (0) | |
def not: {b} | |
if |b == 1| then: 0 else: 1 | |
// ======= Game elements ======= | |
def Air: | |
{Air Wall Unit} | |
Air | |
def Wall: | |
{Air Wall Unit} | |
Wall | |
def Unit: {side flies} | |
{Air Wall Unit} | |
(Unit side flies) | |
// ======= Game ======= | |
def is_opposing_side: {hero} {target} | |
let sideH = (get_side_unit hero) | |
let sideT = (get_side_unit target) | |
get [t0, t1]= cpy sideT | |
if |t0 == BOARD| | |
then: 0 // board is neutral, so do not have a side | |
else: (not |sideH == t1|) | |
def get_side_unit: {ele} | |
let case_air = BOARD | |
let case_wall = BOARD | |
let case_unit = {side} {flies} side | |
(ele case_air case_wall case_unit) | |
def can_atk_element: {ele} {target} | |
let case_air = 0 | |
let case_wall = 0 | |
let case_unit = {side} {flies} (is_opposing_side (Unit side flies) target) | |
(ele case_air case_wall case_unit) | |
def main: | |
let hero = (Unit WHITE 0) | |
let enemy = (Unit BLACK 1) | |
let ally = (Unit WHITE 1) | |
let air = Air | |
let wall = Wall | |
(can_atk_element enemy air) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment