bigtime renaming

This commit is contained in:
ntr 2019-05-25 15:20:38 +10:00
parent 4800609df7
commit 760106e0e7
91 changed files with 1643 additions and 1616 deletions

View File

@ -22,8 +22,8 @@ Added `Buff` as a skill
*BALANCE* *BALANCE*
- purify - purify
- 1 effect from all cryps at level 2 - 1 effect from all constructs at level 2
- removes all effects from all cryps at l3 - removes all effects from all constructs at l3
- invert - invert
- fx for buffs when applied to enemies - fx for buffs when applied to enemies

View File

@ -5,7 +5,7 @@ specs [spec [bonus amount, [r g b]]
# Playthrough # Playthrough
cryps join game constructs join game
stats randomised stats randomised
initial stash drops initial stash drops

View File

@ -23,9 +23,9 @@ Base specs have a base 3 cost
### Actual Costs ### Actual Costs
- Costs increase as more of an item is used on cryps in the game - Costs increase as more of an item is used on constructs in the game
- The cost increases by the base cost for every 6 allocations of base item - The cost increases by the base cost for every 6 allocations of base item
- Allocation is based on all cryps in the game - Allocation is based on all constructs in the game
### Example ### ### Example ###
@ -33,15 +33,15 @@ Round #1
All costs are base costs All costs are base costs
# Player #1 and Player #2 (They both bought the same things) # Player #1 and Player #2 (They both bought the same things)
Cryp #1 Strike (Attack + RR), (2 + 1 + 1) = (4) cost Construct #1 Strike (Attack + RR), (2 + 1 + 1) = (4) cost
Cryp #1 Empower (Buff + RR), (2 + 1 + 1) = (4) cost Construct #1 Empower (Buff + RR), (2 + 1 + 1) = (4) cost
Cryp #3 Attack, 2 cost Construct #3 Attack, 2 cost
Total cost - 10 Total cost - 10
Round #2 Round #2
Items used on cryps include: Items used on constructs include:
Red x 8 Red x 8
Attack x 4 Attack x 4
@ -52,9 +52,9 @@ The costs of red for round #2 are now (1 + 1) = 2
If they were to buy the same skill setup it would be as follows: If they were to buy the same skill setup it would be as follows:
# Player #1 and Player #2 (They both bought the same things) # Player #1 and Player #2 (They both bought the same things)
Cryp #1 Strike (Attack + RR), (2 + 2 + 2) = (6) cost Construct #1 Strike (Attack + RR), (2 + 2 + 2) = (6) cost
Cryp #1 Empower (Buff + RR), (2 + 2 + 2) = (6) cost Construct #1 Empower (Buff + RR), (2 + 2 + 2) = (6) cost
Cryp #3 Attack, 2 cost Construct #3 Attack, 2 cost
Total cost - 14 Total cost - 14

View File

@ -46,4 +46,4 @@ Rare `increased speed, increased cooldowns`
- Increased stat - Increased stat
- ??? Related Notables - ??? Related Notables
# ??? Cryps need to have a minimum of X of the cryp stat to learn a skill # # ??? Constructs need to have a minimum of X of the construct stat to learn a skill #

View File

@ -1,4 +1,4 @@
# Cryps ("creeps") # Constructs ("creeps")
## Combat ## Combat
@ -30,7 +30,7 @@ resolve phase:
| reduction | absorption? | durations | | reduction | absorption? | durations |
## Cryp Alignments ## Construct Alignments
Natural Selection Natural Selection
================ ================
@ -92,7 +92,7 @@ Path to Destruction
Damage & Destruction Damage & Destruction
------------------------- -------------------------
cryps walking the path to destruction have forsaken themselves in order to gain ruinous power. constructs walking the path to destruction have forsaken themselves in order to gain ruinous power.
no price is too high, they gladly harm themselves and allies to amplify the destruction they wreak on everything around them no price is too high, they gladly harm themselves and allies to amplify the destruction they wreak on everything around them
specialise in magical damage dealing specialise in magical damage dealing
@ -124,7 +124,7 @@ Universal Chaos
The only constant is change. The only constant is change.
---------------------------- ----------------------------
Cryps aligning themselves with the forces of chaos believe that constant change is the only truth in the universe. Constructs aligning themselves with the forces of chaos believe that constant change is the only truth in the universe.
They harness its power to manipulate physical reality as well as control and disrupt the flow of battle. They harness its power to manipulate physical reality as well as control and disrupt the flow of battle.
They blend between physical and astral forms, constantly shifting throughout time and space. They blend between physical and astral forms, constantly shifting throughout time and space.

View File

@ -22,7 +22,7 @@ Combat animations
Make in game shop Make in game shop
Payment processors / CC etc Payment processors / CC etc
Handler for game purchases Handler for game purchases
MTX - Cryp Avatars MTX - Construct Avatars
MTX - Skill anims MTX - Skill anims
Setup company bank accounts Setup company bank accounts
@ -42,3 +42,22 @@ Marketing materials
Twitch Twitch
Advertisments? Advertisments?
Information Information
# china shit
You need to read the details more carefully. Playsaurus messed up:
1. They launched in China without registering a trademark
2. A competitor registered the trademark after 3 months of their launch
3. They continued to sell for 4 years under a name trademarked by another company, making $73,000+ yearly from that one country
Now, they complain about it on Reddit, even though China is a 'First to File' company.
The fault lies entirely with Playsaurus, nothing illegal occurred here.
https://www.trademarknow.com/blog/first-to-file-versus-first...
This situation could have occurred in many other countries - the difference is probably that the competitor is content to just sell in China, under a Chinese name, whereas products sold anywhere else would need to use the English name.

View File

@ -4,16 +4,16 @@ Numbers are placeholder
`Specs get a bonus dependent on the total of Red / Green / Blue in player skills & specs` `Specs get a bonus dependent on the total of Red / Green / Blue in player skills & specs`
# Example to meet 5 red gem bonus from skills only # Example to meet 5 red gem bonus from skills only
In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has `Snare` In your player Construct #1 has `Strike`, Construct #2 has `Slay` and `Heal`, Construct #3 has `Snare`
- RR skill `Strike` contributes 2 red gems to the total red gems (2 total) - RR skill `Strike` contributes 2 red gems to the total red gems (2 total)
- RG skill `Slay` contributes 1 red gem to the total red gems (3 total) - RG skill `Slay` contributes 1 red gem to the total red gems (3 total)
- GG skill `Heal` contirubtes 0 red gems to the total red gems (3 total) - GG skill `Heal` contirubtes 0 red gems to the total red gems (3 total)
- RR skill `Snare` contirubtes 2 red gems to the total red gems (5 total) - RR skill `Snare` contirubtes 2 red gems to the total red gems (5 total)
# Advanced specs also require a minimum number of Red / Green / Blue gems on the cryp to take effect # Advanced specs also require a minimum number of Red / Green / Blue gems on the construct to take effect
- Tier 1 Basic specs (Damage / Health / Defense) will have no requirements - Tier 1 Basic specs (Damage / Health / Defense) will have no requirements
- Advanced specs will require a certain threshold of red / green / blue gems to be enabled - Advanced specs will require a certain threshold of red / green / blue gems to be enabled
- Provided spec requirements are met, all specs will add gems to the cryp - Provided spec requirements are met, all specs will add gems to the construct
# Starting from scratch with a vbox # Starting from scratch with a vbox
@ -26,9 +26,9 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has
Combine 2 Red + 'Attack' -> Strike Combine 2 Red + 'Attack' -> Strike
Combine 2 Red + 'Basic Damage Spec' -> Red Damage Combine 2 Red + 'Basic Damage Spec' -> Red Damage
Cryp #1 -> Give Strike & Red Damage Spec -> Strike + 1 x Red Damage Spec Construct #1 -> Give Strike & Red Damage Spec -> Strike + 1 x Red Damage Spec
Cryp #2 -> Give Attack -> Attack Construct #2 -> Give Attack -> Attack
Cryp #3 -> Give Stun -> Stun Construct #3 -> Give Stun -> Stun
Player Total (4 Red + 2 Basic gems) Player Total (4 Red + 2 Basic gems)
@ -37,17 +37,17 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has
- Buy 2 reds & 2 green & 2 blue (all available colour items) - Buy 2 reds & 2 green & 2 blue (all available colour items)
- Buy 2 Basic Damage Spec (item) - Buy 2 Basic Damage Spec (item)
- Cryp #2 Unequip Attack - Construct #2 Unequip Attack
- Combine 2 Green + 'Attack' -> Heal - Combine 2 Green + 'Attack' -> Heal
- Cryp #3 Unequip Stun - Construct #3 Unequip Stun
- Combine 2 Blue + 'Stun' -> Ruin - Combine 2 Blue + 'Stun' -> Ruin
- Combine 2 Red + 'Basic Damage Spec' -> Red Damage - Combine 2 Red + 'Basic Damage Spec' -> Red Damage
Cryp #1 -> Give Red Damage items -> Strike + 2 x Red Damage Spec (6R) Construct #1 -> Give Red Damage items -> Strike + 2 x Red Damage Spec (6R)
Cryp #2 -> Give Heal item -> Heal (2G) Construct #2 -> Give Heal item -> Heal (2G)
Cryp #3 -> Give Ruin item -> Ruin (2B) Construct #3 -> Give Ruin item -> Ruin (2B)
## Round 3 ## Round 3
@ -58,9 +58,9 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has
- Combine 2 Red + 'Stun' -> Strangle - Combine 2 Red + 'Stun' -> Strangle
- Combine 2 Red + 'Block' -> Parry - Combine 2 Red + 'Block' -> Parry
Cryp #1 -> Give 'Stun' & 'Strangle' -> Strike, Stun, Strangle + 2 x Red Damage Spec (10R) Construct #1 -> Give 'Stun' & 'Strangle' -> Strike, Stun, Strangle + 2 x Red Damage Spec (10R)
Cryp #2 -> 'No change' -> Heal (2G) Construct #2 -> 'No change' -> Heal (2G)
Cryp #3 -> Give Attack item & 2 Basic Damage Spec -> Attack + Ruin + 2 x Basic Damage Spec (2B) Construct #3 -> Give Attack item & 2 Basic Damage Spec -> Attack + Ruin + 2 x Basic Damage Spec (2B)
## Round 4 ## Round 4
@ -70,18 +70,18 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has
- Combine 2 Red + 'Attack' -> Strike - Combine 2 Red + 'Attack' -> Strike
- Combine 2 Red + 'Buff' -> Empower - Combine 2 Red + 'Buff' -> Empower
- Cryp #1 Unequip 2 x Red Damage spec, Equip Empower -> Strike, Stun, Strangle, Empower (8R) - Construct #1 Unequip 2 x Red Damage spec, Equip Empower -> Strike, Stun, Strangle, Empower (8R)
- Combine 'Strike' + 2 x Red Damage spec -> 'Increased Strike Damage spec' - Combine 'Strike' + 2 x Red Damage spec -> 'Increased Strike Damage spec'
### Note 'Increased Strike Damage spec' requires 8R on the cryp ### Note 'Increased Strike Damage spec' requires 8R on the construct
Cryp #1 Equip Increased Strike Damage spec -> Strike, Stun, Strangle, Empower + Increased Strike Damage Spec (14R) Construct #1 Equip Increased Strike Damage spec -> Strike, Stun, Strangle, Empower + Increased Strike Damage Spec (14R)
Cryp #2 -> 'No change' -> Heal Construct #2 -> 'No change' -> Heal
Cryp #3 -> 'No change' -> Attack + Ruin + 2 x Basic Damage Spec Construct #3 -> 'No change' -> Attack + Ruin + 2 x Basic Damage Spec
## Round 5 ## Round 5
We already lost cause we went all in on 1 red cryp like a noob We already lost cause we went all in on 1 red construct like a noob
### Generic Specs ### Generic Specs
@ -96,7 +96,7 @@ Maximum 35% inc hp
Maximum 50% inc speed Maximum 50% inc speed
# Basic Class Spec # Basic Class Spec
`Base` -> +2 red, +2 green +2 blue gems on cryp `Base` -> +2 red, +2 green +2 blue gems on construct
# Basic Duration # Basic Duration
### Increased Damage Combos ### ### Increased Damage Combos ###
@ -182,32 +182,32 @@ Maximum +35% inc blue shield and 35% inc red shield
## Upgraded Attack Spec Combos ## Upgraded Attack Spec Combos
# Increased Strike Damage (Combine Strike + Red Damage Spec x 2) # Increased Strike Damage (Combine Strike + Red Damage Spec x 2)
Cryp Requires `8 red gems` Construct Requires `8 red gems`
Adds `6 red gems` Adds `6 red gems`
`Base` -> 15% increased strike damage `Base` -> 15% increased strike damage
`Player Bonus` 15 red gems -> +15% // 20 red gems -> +20% // 30 red gems -> +30% `Player Bonus` 15 red gems -> +15% // 20 red gems -> +20% // 30 red gems -> +30%
Maximum 80% increased strike damage Maximum 80% increased strike damage
# Improved Heal (Combine Heal + Healing Spec x 2) # Improved Heal (Combine Heal + Healing Spec x 2)
Cryp Requires `8 green gems` Construct Requires `8 green gems`
`Base` -> 15% increased heal healing `Base` -> 15% increased heal healing
`Player Bonus` 15 green gems -> +15% // 20 green gems -> +20% // 30 green gems -> +30% `Player Bonus` 15 green gems -> +15% // 20 green gems -> +20% // 30 green gems -> +30%
Maximum 80% increased heal healing Maximum 80% increased heal healing
# Increased Blast Damage (Combine Blast + Blue Spec x 2) # Increased Blast Damage (Combine Blast + Blue Spec x 2)
Cryp Requires `8 blue gems` Construct Requires `8 blue gems`
`Base` -> 15% increased blast damage `Base` -> 15% increased blast damage
`Player Bonus` 15 blue gems -> +15% // 20 blue gems -> +20% // 30 blue gems -> +30% `Player Bonus` 15 blue gems -> +15% // 20 blue gems -> +20% // 30 blue gems -> +30%
Maximum 80% increased blast damage Maximum 80% increased blast damage
# Increased Slay Damage (Combine Slay + Red Damage Spec + Healing Spec) # Increased Slay Damage (Combine Slay + Red Damage Spec + Healing Spec)
Cryp Requires `4 red 4 green gems` Construct Requires `4 red 4 green gems`
`Base` -> 15% increased slay damage `Base` -> 15% increased slay damage
`Player Bonus` (8R + 8G) gems -> +15% // (10R + 10G) gems -> +20% // (15R + 15G) gems -> +30% `Player Bonus` (8R + 8G) gems -> +15% // (10R + 10G) gems -> +20% // (15R + 15G) gems -> +30%
Maximum 80% increased slay damage Maximum 80% increased slay damage
# Increased Banish Damage (Combine Slay + Red Damage Spec + Blue Damage Spec) # Increased Banish Damage (Combine Slay + Red Damage Spec + Blue Damage Spec)
Cryp Requires `4 red 4 blue gems` Construct Requires `4 red 4 blue gems`
`Base` -> 15% increased slay damage `Base` -> 15% increased slay damage
`Player Bonus` (8R + 8B) gems -> +15% // (10R + 10B) gems -> +20% // (15R + 15B) gems -> +30% `Player Bonus` (8R + 8B) gems -> +15% // (10R + 10B) gems -> +20% // (15R + 15B) gems -> +30%
Maximum 80% increased banish damage Maximum 80% increased banish damage

View File

@ -24,8 +24,8 @@ Tidy edges on game UI
blue + defensive green blue + defensive green
- purify - purify
- 1 effect from all cryps at level 2 - 1 effect from all constructs at level 2
- removes all effects from all cryps at l3 - removes all effects from all constructs at l3
- invert - invert
- fx for buffs when applied to enemies - fx for buffs when applied to enemies
@ -102,7 +102,7 @@ push events
$$$ $$$
* Items * Items
* Colour scheme * Colour scheme
* number of cryps * number of constructs
* Highlight (dota) colour * Highlight (dota) colour
* fx colours + styles * fx colours + styles

View File

@ -36,7 +36,7 @@
} }
.opponent .game-cryp { .opponent .game-construct {
align-items: flex-start; align-items: flex-start;
grid-template-rows: min-content min-content min-content 2fr; grid-template-rows: min-content min-content min-content 2fr;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
@ -47,12 +47,12 @@
"avatar target"; "avatar target";
} }
.opponent .game-cryp .name { .opponent .game-construct .name {
margin-bottom: 0; margin-bottom: 0;
margin-top: 0.25em; margin-top: 0.25em;
} }
.game-cryp { .game-construct {
display: grid; display: grid;
/*justify-items: center;*/ /*justify-items: center;*/
@ -74,7 +74,7 @@
transition-timing-function: ease; transition-timing-function: ease;
} }
.game-cryp .targeting { .game-construct .targeting {
grid-area: target; grid-area: target;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
@ -84,36 +84,36 @@
white-space: nowrap; white-space: nowrap;
} }
.game-cryp .img { .game-construct .img {
grid-area: avatar; grid-area: avatar;
} }
.game-cryp .name { .game-construct .name {
width: 100%; width: 100%;
margin-bottom: 0.25em; margin-bottom: 0.25em;
text-align: center; text-align: center;
grid-area: name; grid-area: name;
} }
.game-cryp .stats { .game-construct .stats {
grid-area: stats; grid-area: stats;
display: flex; display: flex;
flex-flow: row; flex-flow: row;
} }
.game-cryp figure { .game-construct figure {
padding: 0 0.5em; padding: 0 0.5em;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
} }
.game-cryp figcaption { .game-construct figcaption {
white-space: nowrap; white-space: nowrap;
font-size: 100%; font-size: 100%;
} }
@media (max-width: 1500px) { @media (max-width: 1500px) {
.game-cryp figure { .game-construct figure {
padding: 0 0.25em; padding: 0 0.25em;
} }
@ -123,7 +123,7 @@
} }
*/} */}
.game-cryp .skills { .game-construct .skills {
grid-area: skills; grid-area: skills;
display: flex; display: flex;
flex-flow: column-reverse; flex-flow: column-reverse;
@ -131,13 +131,13 @@
} }
/*@media (max-width: 1000px) { /*@media (max-width: 1000px) {
.game-cryp .skills { .game-construct .skills {
flex-flow: column; flex-flow: column;
} }
} }
*/ */
.game-cryp .effects { .game-construct .effects {
grid-area: effects; grid-area: effects;
font-size: 1.5em; font-size: 1.5em;
white-space: nowrap; white-space: nowrap;
@ -153,7 +153,7 @@
margin-right: 0.5em; margin-right: 0.5em;
} }
.game-cryp button { .game-construct button {
color: #888; color: #888;
flex: 1 1 100%; flex: 1 1 100%;
padding: 0; padding: 0;
@ -161,35 +161,35 @@
border-width: 0px; border-width: 0px;
} }
.game-cryp button.active { .game-construct button.active {
color: whitesmoke; color: whitesmoke;
} }
.game-cryp button[disabled], .game-cryp button[disabled]:hover { .game-construct button[disabled], .game-construct button[disabled]:hover {
color: #333333; color: #333333;
text-decoration: line-through text-decoration: line-through
} }
.game-cryp button:hover { .game-construct button:hover {
color: whitesmoke; color: whitesmoke;
} }
.game-cryp.ko { .game-construct.ko {
animation: none; animation: none;
opacity: 0.35; opacity: 0.35;
filter: grayscale(100%); filter: grayscale(100%);
} }
.game-cryp.ko button:hover { .game-construct.ko button:hover {
color: #333; color: #333;
} }
.game-cryp.unfocus { .game-construct.unfocus {
opacity: 0.65; opacity: 0.65;
filter: blur(5px); filter: blur(5px);
} }
.game-cryp.unfocus.ko { .game-construct.unfocus.ko {
filter: blur(5px) grayscale(100%); filter: blur(5px) grayscale(100%);
} }
@ -202,18 +202,18 @@
left: 50%; left: 50%;
} }
CRYP DAMAGE CONSTRUCT DAMAGE
.game-cryp.active-skill { .game-construct.active-skill {
filter: drop-shadow(0 0 0.2em silver); filter: drop-shadow(0 0 0.2em silver);
/*border-color: silver;*/ /*border-color: silver;*/
} }
.game-cryp.red-damage { .game-construct.red-damage {
filter: drop-shadow(0 0 0.2em red); filter: drop-shadow(0 0 0.2em red);
color: red; color: red;
/*ensure cryp doesn't get opacity lowered because of being KO before the KO animation*/ /*ensure construct doesn't get opacity lowered because of being KO before the KO animation*/
opacity: 1; opacity: 1;
/*border-color: red;*/ /*border-color: red;*/
@ -232,7 +232,7 @@ CRYP DAMAGE
/*border-top: 1px solid red;*/ /*border-top: 1px solid red;*/
} }
.game-cryp.blue-damage { .game-construct.blue-damage {
filter: drop-shadow(0 0 0.2em blue); filter: drop-shadow(0 0 0.2em blue);
color: blue; color: blue;
opacity: 1; opacity: 1;
@ -252,7 +252,7 @@ CRYP DAMAGE
/*border-top: 1px solid blue;*/ /*border-top: 1px solid blue;*/
} }
.game-cryp.green-damage { .game-construct.green-damage {
filter: drop-shadow(0 0 0.2em green); filter: drop-shadow(0 0 0.2em green);
color: green; color: green;
opacity: 1; opacity: 1;
@ -272,7 +272,7 @@ CRYP DAMAGE
/*border-top: 1px solid green;*/ /*border-top: 1px solid green;*/
} }
.game-cryp.purple-damage { .game-construct.purple-damage {
filter: drop-shadow(0 0 0.2em purple); filter: drop-shadow(0 0 0.2em purple);
color: purple; color: purple;
border-color: purple; border-color: purple;

View File

@ -11,7 +11,7 @@
"top top info" "top top info"
"vbox vbox info" "vbox vbox info"
"equip equip info" "equip equip info"
"cryps cryps info"; "constructs constructs info";
} }
@media (max-width: 1920px) { @media (max-width: 1920px) {
@ -33,7 +33,7 @@
} }
.instance .scoreboard { .instance .scoreboard {
grid-area: cryps; grid-area: constructs;
} }
.instance-ui-btn { .instance-ui-btn {
@ -60,8 +60,8 @@
margin-top: 1.5em; margin-top: 1.5em;
} }
.instance .cryps { .instance .constructs {
grid-area: cryps; grid-area: constructs;
} }
.instance .equip { .instance .equip {
@ -148,16 +148,16 @@
cursor: pointer; cursor: pointer;
} }
/* CRYP LIST */ /* CONSTRUCT LIST */
.cryp-list { .construct-list {
grid-area: cryps; grid-area: constructs;
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
} }
.instance-cryp, .instance-cryp-active { .instance-construct, .instance-construct-active {
display: grid; display: grid;
grid-template-rows: min-content min-content min-content 1fr min-content; grid-template-rows: min-content min-content min-content 1fr min-content;
grid-template-areas: grid-template-areas:
@ -177,17 +177,17 @@
transition-timing-function: ease; transition-timing-function: ease;
*/} */}
.instance-cryp:first-child, .instance-cryp-active:first-child { .instance-construct:first-child, .instance-construct-active:first-child {
margin-left: 0; margin-left: 0;
border-left-width: 1px; border-left-width: 1px;
} }
.cryp-list .name { .construct-list .name {
grid-area: name; grid-area: name;
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.cryp-list .avatar { .construct-list .avatar {
grid-area: avatar; grid-area: avatar;
object-fit: contain; object-fit: contain;
background-size: contain; background-size: contain;
@ -196,28 +196,28 @@
pointer-events: none; pointer-events: none;
} }
.cryp-list .name { .construct-list .name {
text-align: center; text-align: center;
} }
.cryp-list .avatar figure { .construct-list .avatar figure {
margin: 0; margin: 0;
height: 80%; height: 80%;
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
} }
.cryp-list .avatar figcaption { .construct-list .avatar figcaption {
font-size: 90%; font-size: 90%;
} }
.cryp-list .skills { .construct-list .skills {
grid-area: skills; grid-area: skills;
display: flex; display: flex;
border-width: 0px; border-width: 0px;
} }
.cryp-list .skills button { .construct-list .skills button {
flex: 1; flex: 1;
border-width: 0px; border-width: 0px;
} }
@ -236,7 +236,7 @@
} }
} }
*/ */
.cryp-list .specs { .construct-list .specs {
margin-top: 1em; margin-top: 1em;
grid-area: specs; grid-area: specs;
display: flex; display: flex;
@ -245,18 +245,18 @@
border-width: 0px; border-width: 0px;
} }
.cryp-list .specs figure { .construct-list .specs figure {
flex: 1; flex: 1;
border: 0; border: 0;
align-items: center; align-items: center;
text-align: center; text-align: center;
} }
.cryp-list .specs figcaption { .construct-list .specs figcaption {
font-size: 75%; font-size: 75%;
} }
.cryp-list .stats { .construct-list .stats {
grid-area: stats; grid-area: stats;
display: grid; display: grid;
grid-template-rows: 1fr 3fr; grid-template-rows: 1fr 3fr;
@ -267,11 +267,11 @@
border-width: 0px; border-width: 0px;
} }
.cryp-list .stats figcaption { .construct-list .stats figcaption {
font-size: 75%; font-size: 75%;
} }
.cryp-list .stats .icons { .construct-list .stats .icons {
grid-area: st; grid-area: st;
display: flex; display: flex;
flex-flow: row; flex-flow: row;
@ -289,25 +289,25 @@
fill: none; fill: none;
} }
.cryp-list .stat-icon { .construct-list .stat-icon {
width: 100%; width: 100%;
} }
.cryp-list .stats .damage-label { .construct-list .stats .damage-label {
grid-area: dl; grid-area: dl;
display: flex; display: flex;
justify-content: center; justify-content: center;
color: #666; color: #666;
} }
.cryp-list .stats .speed-label { .construct-list .stats .speed-label {
grid-area: sl; grid-area: sl;
display: flex; display: flex;
justify-content: center; justify-content: center;
color: #666; color: #666;
} }
.cryp-list .stats .life-label { .construct-list .stats .life-label {
grid-area: ll; grid-area: ll;
display: flex; display: flex;
justify-content: center; justify-content: center;

View File

@ -7,12 +7,12 @@
"top" "top"
"controls" "controls"
"vbox" "vbox"
"cryps" "constructs"
} }
/* Default view */ /* Default view */
.instance .equip { display: none; } .instance .equip { display: none; }
.instance .info { display: none; } .instance .info { display: none; }
.instance .cryp-list { display: none; } .instance .construct-list { display: none; }
.vbox { .vbox {
grid-area: vbox; grid-area: vbox;
display: grid; display: grid;
@ -31,13 +31,13 @@
.vbox-combiner { .vbox-combiner {
margin-left: 0; margin-left: 0;
} }
/* Toggled view (cryps)*/ /* Toggled view (constructs)*/
#toggle-vbox-label { #toggle-vbox-label {
text-align: center; text-align: center;
border: 2px solid #555; border: 2px solid #555;
} }
#toggle-vbox-label:after{ #toggle-vbox-label:after{
content: "Cryps"; content: "Constructs";
} }
#toggle-vbox:checked ~ #toggle-vbox-label:after{ #toggle-vbox:checked ~ #toggle-vbox-label:after{
@ -54,8 +54,8 @@
display: initial; display: initial;
} }
#toggle-vbox:checked ~ .cryp-list { #toggle-vbox:checked ~ .construct-list {
grid-area: cryps; grid-area: constructs;
display: grid; display: grid;
justify-content: center; justify-content: center;
@ -75,12 +75,12 @@
margin-right: 0.5em; margin-right: 0.5em;
} }
.cryp-list .skills { .construct-list .skills {
flex-flow: row; flex-flow: row;
align-items: stretch; align-items: stretch;
} }
.instance-cryp { .instance-construct {
grid-row: 2; grid-row: 2;
display: grid; display: grid;
grid-template-rows: min-content 1fr; grid-template-rows: min-content 1fr;
@ -95,20 +95,20 @@
transition-timing-function: ease; transition-timing-function: ease;
} }
.instance-cryp .skills { .instance-construct .skills {
display: none; display: none;
} }
.instance-cryp .specs { .instance-construct .specs {
display: none; display: none;
} }
.instance-cryp .stats { .instance-construct .stats {
display: none; display: none;
} }
.instance-cryp-active { .instance-construct-active {
grid-row: 1; grid-row: 1;
grid-column: 1 / 3; grid-column: 1 / 3;
display: grid; display: grid;
@ -129,11 +129,11 @@
transition-timing-function: ease; transition-timing-function: ease;
} }
.instance-cryp-active img { .instance-construct-active img {
width: 55px; width: 55px;
} }
/* Cryp Stuff */ /* Construct Stuff */
} }

View File

@ -2,7 +2,7 @@
GLOBAL GLOBAL
*/ */
html, body, #cryps { html, body, #constructs {
/*width: 100%;*/ /*width: 100%;*/
margin: 0; margin: 0;
@ -61,7 +61,7 @@ figure {
text-align: center; text-align: center;
} }
#cryps { #constructs {
padding: 0 2em; padding: 0 2em;
display: grid; display: grid;
grid-template-columns: 1fr 8fr; grid-template-columns: 1fr 8fr;
@ -277,13 +277,13 @@ button[disabled] {
flex-flow: column; flex-flow: column;
} }
#cryps input, #cryps select { #constructs input, #constructs select {
border-color: #444; border-color: #444;
background-color: #333; background-color: #333;
border-radius: 0; border-radius: 0;
} }
#cryps input:focus { #constructs input:focus {
border-color: whitesmoke; border-color: whitesmoke;
} }
@ -349,7 +349,7 @@ header {
MENU MENU
*/ */
.menu-cryps { .menu-constructs {
display: grid; display: grid;
grid-template-rows: min-content min-content; grid-template-rows: min-content min-content;
@ -358,14 +358,14 @@ header {
"list"; "list";
} }
.menu-cryps .list { .menu-constructs .list {
grid-area: list; grid-area: list;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
} }
.menu-cryp-ctr { .menu-construct-ctr {
/*flex: 0 0 30%;*/ /*flex: 0 0 30%;*/
display: flex; display: flex;
@ -374,7 +374,7 @@ header {
justify-content: center; justify-content: center;
} }
.spawn-btn .menu-cryp { .spawn-btn .menu-construct {
border: 1px solid #333; border: 1px solid #333;
color: #333; color: #333;
display: flex; display: flex;
@ -399,7 +399,7 @@ header {
opacity: 0 opacity: 0
} }
.menu-cryp { .menu-construct {
height: 100%; height: 100%;
margin: 0.5em; margin: 0.5em;
box-sizing: border-box; box-sizing: border-box;
@ -512,7 +512,7 @@ main .top {
} }
@media (max-height: 900px), (max-width: 1500px) { @media (max-height: 900px), (max-width: 1500px) {
#cryps { #constructs {
font-size: 75%; font-size: 75%;
} }

View File

@ -1,5 +1,5 @@
@media (max-height: 800px), (max-width: 1000px) { @media (max-height: 800px), (max-width: 1000px) {
#cryps { #constructs {
font-size: 8pt; font-size: 8pt;
padding: 0; padding: 0;
grid-template-columns: min-content 1fr; grid-template-columns: min-content 1fr;

View File

@ -1,12 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>cryps.gg - mnml pvp atbs</title> <title>mnml pvp tbs</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black> <meta name=apple-mobile-web-app-status-bar-style content=black>
<meta name="description" content="cryps.gg - mnml pvp atbs"> <meta name="description" content="mnml pvp tbs">
<meta name="author" content="ntr@smokestack.io"> <meta name="author" content="ntr@smokestack.io">
<link rel="manifest" href="manifest.webmanifest"> <link rel="manifest" href="manifest.webmanifest">
<link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script> <link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script>

View File

@ -1,7 +1,7 @@
{ {
"name": "cryps.gg - mnml pvp atbs", "name": "constructs.gg - mnml pvp atbs",
"description": "cryps.gg - mnml pvp atbs", "description": "constructs.gg - mnml pvp atbs",
"short_name": "cryps.gg", "short_name": "constructs.gg",
"icons": [ "icons": [
{ {
"src": "./assets/icons/726.png", "src": "./assets/icons/726.png",

View File

@ -1,5 +1,5 @@
{ {
"name": "cryps-client", "name": "mnml-client",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",

View File

@ -1,5 +1,5 @@
export const setAccount = value => ({ type: 'SET_ACCOUNT', value }); export const setAccount = value => ({ type: 'SET_ACCOUNT', value });
export const setCryps = value => ({ type: 'SET_CRYPS', value }); export const setConstructs = value => ({ type: 'SET_CONSTRUCTS', value });
export const setItemInfo = value => ({ type: 'SET_ITEM_INFO', value }); export const setItemInfo = value => ({ type: 'SET_ITEM_INFO', value });
export const setSkip = value => ({ type: 'SET_SKIP', value }); export const setSkip = value => ({ type: 'SET_SKIP', value });
export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value });
@ -11,9 +11,9 @@ export const setGame = value => ({ type: 'SET_GAME', value });
export const setResolution = value => ({ type: 'SET_RESOLUTION', value }); export const setResolution = value => ({ type: 'SET_RESOLUTION', value });
export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value }); export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value });
export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) }); export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) });
export const setTeam = value => ({ type: 'SET_SELECTED_CRYPS', value: Array.from(value) }); export const setTeam = value => ({ type: 'SET_SELECTED_CONSTRUCTS', value: Array.from(value) });
export const setActiveSkill = (crypId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: crypId ? { crypId, skill } : null }); export const setActiveSkill = (constructId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: constructId ? { constructId, skill } : null });
export const setActiveCryp = value => ({ type: 'SET_ACTIVE_CRYP', value }); export const setActiveConstruct = value => ({ type: 'SET_ACTIVE_CONSTRUCT', value });
export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value }); export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value });
export const setInfo = value => ({ type: 'SET_INFO', value }); export const setInfo = value => ({ type: 'SET_INFO', value });
export const setItemEquip = value => ({ type: 'SET_ITEM_EQUIP', value }); export const setItemEquip = value => ({ type: 'SET_ITEM_EQUIP', value });

View File

@ -28,8 +28,8 @@ document.fonts.load('16pt "Jura"').then(() => {
store.dispatch(actions.setWs(ws)); store.dispatch(actions.setWs(ws));
ws.connect(); ws.connect();
const Cryps = () => ( const Constructs = () => (
<div id="cryps" > <div id="constructs" >
<input type="checkbox" id="toggle-nav"/> <input type="checkbox" id="toggle-nav"/>
<label id="toggle-nav-label" htmlFor="toggle-nav"><i className="fa fa-bars"></i></label> <label id="toggle-nav-label" htmlFor="toggle-nav"><i className="fa fa-bars"></i></label>
<Header /> <Header />
@ -40,7 +40,7 @@ document.fonts.load('16pt "Jura"').then(() => {
const App = () => ( const App = () => (
<Provider store={store}> <Provider store={store}>
<Cryps /> <Constructs />
</Provider> </Provider>
); );

View File

@ -1,6 +1,6 @@
const preact = require('preact'); const preact = require('preact');
function renderSpawnButton({ account, sendCrypSpawn }) { function renderSpawnButton({ account, sendConstructSpawn }) {
let name = ''; let name = '';
if (!account) return <div>...</div>; if (!account) return <div>...</div>;
@ -13,7 +13,7 @@ function renderSpawnButton({ account, sendCrypSpawn }) {
<input <input
className="input" className="input"
type="text" type="text"
placeholder="cryp name" placeholder="construct name"
onChange={e => (name = e.target.value)} onChange={e => (name = e.target.value)}
/> />
</div> </div>
@ -21,7 +21,7 @@ function renderSpawnButton({ account, sendCrypSpawn }) {
<button <button
className="button" className="button"
type="submit" type="submit"
onClick={() => sendCrypSpawn(name)}> onClick={() => sendConstructSpawn(name)}>
Spawn 👾 Spawn 👾
</button> </button>
</div> </div>

View File

@ -1,16 +1,16 @@
const { connect } = require('react-redux'); const { connect } = require('react-redux');
const CrypSpawnButton = require('./cryp.spawn.button'); const ConstructSpawnButton = require('./construct.spawn.button');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws } = state; const { ws } = state;
function sendCrypSpawn(name) { function sendConstructSpawn(name) {
return ws.sendCrypSpawn(name); return ws.sendConstructSpawn(name);
} }
return { account: state.account, sendCrypSpawn }; return { account: state.account, sendConstructSpawn };
} }
); );
module.exports = addState(CrypSpawnButton); module.exports = addState(ConstructSpawnButton);

View File

@ -1,7 +1,7 @@
const preact = require('preact'); const preact = require('preact');
const { STATS, eventClasses, getCombatText, crypAvatar } = require('../utils'); const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils');
const { animationDivs } = require('../animations'); const { animationDivs } = require('../animations');
const GameCryp = require('./game.cryp'); const GameConstruct = require('./game.construct');
function GamePanel(props) { function GamePanel(props) {
const { const {
@ -10,7 +10,7 @@ function GamePanel(props) {
resolution, resolution,
activeSkill, activeSkill,
setActiveSkill, setActiveSkill,
setActiveCryp, setActiveConstruct,
selectSkillTarget, selectSkillTarget,
sendInstanceState, sendInstanceState,
sendGameReady, sendGameReady,
@ -76,9 +76,9 @@ function GamePanel(props) {
</div> </div>
); );
function findCryp(id) { function findConstruct(id) {
const team = game.players.find(t => t.cryps.find(c => c.id === id)); const team = game.players.find(t => t.constructs.find(c => c.id === id));
if (team) return team.cryps.find(c => c.id === id); if (team) return team.constructs.find(c => c.id === id);
return null; return null;
} }
@ -109,39 +109,39 @@ function GamePanel(props) {
); );
function PlayerTeam(team) { function PlayerTeam(team) {
const cryps = team.cryps.map((c, i) => <GameCryp key={c.id} cryp={c} />); const constructs = team.constructs.map((c, i) => <GameConstruct key={c.id} construct={c} />);
return ( return (
<div className="team player"> <div className="team player">
{cryps} {constructs}
</div> </div>
); );
} }
function OpponentCryp(cryp, i) { function OpponentConstruct(construct, i) {
const ko = cryp.green_life.value === 0 ? 'ko' : ''; const ko = construct.green_life.value === 0 ? 'ko' : '';
const classes = eventClasses(resolution, cryp); const classes = eventClasses(resolution, construct);
const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => ( const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => (
<figure key={j} alt={s.stat}> <figure key={j} alt={s.stat}>
{s.svg(`stat-icon ${s.colour}`)} {s.svg(`stat-icon ${s.colour}`)}
<figcaption>{cryp[s.stat].value} / {cryp[s.stat].max}</figcaption> <figcaption>{construct[s.stat].value} / {construct[s.stat].max}</figcaption>
</figure> </figure>
)); ));
const [combatText, combatClass] = getCombatText(cryp, resolution); const [combatText, combatClass] = getCombatText(construct, resolution);
const combatTextClass = `combat-text ${combatClass}`; const combatTextClass = `combat-text ${combatClass}`;
const combatTextEl = combatText const combatTextEl = combatText
? <div className={combatTextClass}>{combatText}</div> ? <div className={combatTextClass}>{combatText}</div>
: null; : null;
const effects = cryp.effects.length const effects = construct.effects.length
? cryp.effects.map(c => <div key={c.effect}>{c.effect} - {c.duration}T</div>) ? construct.effects.map(c => <div key={c.effect}>{c.effect} - {c.duration}T</div>)
: <div>&nbsp;</div>; : <div>&nbsp;</div>;
const playerTeamIds = playerTeam.cryps.map(c => c.id); const playerTeamIds = playerTeam.constructs.map(c => c.id);
const targeting = game.stack const targeting = game.stack
.filter(s => playerTeamIds.includes(s.source_cryp_id) && s.target_cryp_id === cryp.id) .filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id)
.map((s, i) => <h3 key={i}>{`< ${s.skill}`}</h3>); .map((s, i) => <h3 key={i}>{`< ${s.skill}`}</h3>);
const anim = ( const anim = (
@ -153,17 +153,17 @@ function GamePanel(props) {
return ( return (
<div <div
key={i} key={i}
className={`game-cryp ${ko} ${classes}`} className={`game-construct ${ko} ${classes}`}
style={ activeSkill ? { cursor: 'pointer' } : {}} style={ activeSkill ? { cursor: 'pointer' } : {}}
onClick={() => selectSkillTarget(cryp.id)} > onClick={() => selectSkillTarget(construct.id)} >
<div className="stats">{stats}</div> <div className="stats">{stats}</div>
<h3 className="name" >{cryp.name}</h3> <h3 className="name" >{construct.name}</h3>
<div className="effects">{effects}</div> <div className="effects">{effects}</div>
<div className="targeting">{targeting}</div> <div className="targeting">{targeting}</div>
<figure <figure
className="img" className="img"
onClick={() => selectSkillTarget(cryp.id)} > onClick={() => selectSkillTarget(construct.id)} >
{crypAvatar(cryp.name, cryp.id)} {constructAvatar(construct.name, construct.id)}
{combatTextEl} {combatTextEl}
{anim} {anim}
</figure> </figure>
@ -173,10 +173,10 @@ function GamePanel(props) {
function OpponentTeam(team) { function OpponentTeam(team) {
const cryps = team.cryps.map(OpponentCryp); const constructs = team.constructs.map(OpponentConstruct);
return ( return (
<div className="team opponent"> <div className="team opponent">
{cryps} {constructs}
</div> </div>
); );
} }
@ -185,7 +185,7 @@ function GamePanel(props) {
function gameClick(e) { function gameClick(e) {
e.stopPropagation(); e.stopPropagation();
setActiveCryp(null); setActiveConstruct(null);
} }
return ( return (

View File

@ -13,12 +13,12 @@ const addState = connect(
resolution, resolution,
showLog, showLog,
activeSkill, activeSkill,
activeCryp, activeConstruct,
} = state; } = state;
function selectSkillTarget(targetCrypId) { function selectSkillTarget(targetConstructId) {
if (activeSkill) { if (activeSkill) {
return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill); return ws.sendGameSkill(game.id, activeSkill.constructId, targetConstructId, activeSkill.skill);
} }
return false; return false;
} }
@ -34,7 +34,7 @@ const addState = connect(
// intercept self casting skills // intercept self casting skills
if (activeSkill && activeSkill.skill.self_targeting) { if (activeSkill && activeSkill.skill.self_targeting) {
ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill); ws.sendGameSkill(game.id, activeSkill.constructId, null, activeSkill.skill.skill);
} }
return { return {
@ -43,7 +43,7 @@ const addState = connect(
account, account,
resolution, resolution,
activeSkill, activeSkill,
activeCryp, activeConstruct,
selectSkillTarget, selectSkillTarget,
sendInstanceState, sendInstanceState,
sendGameReady, sendGameReady,
@ -51,13 +51,13 @@ const addState = connect(
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
function setActiveSkill(crypId, skill) { function setActiveSkill(constructId, skill) {
dispatch(actions.setActiveSkill(crypId, skill)); dispatch(actions.setActiveSkill(constructId, skill));
// particlesJS(`particles-${crypId}`, config); // particlesJS(`particles-${constructId}`, config);
} }
function setActiveCryp(cryp) { function setActiveConstruct(construct) {
dispatch(actions.setActiveCryp(cryp)); dispatch(actions.setActiveConstruct(construct));
} }
function quit() { function quit() {
@ -73,7 +73,7 @@ const addState = connect(
dispatch(actions.setSkip(true)); dispatch(actions.setSkip(true));
} }
return { setActiveSkill, setActiveCryp, quit, toggleLog, skip }; return { setActiveSkill, setActiveConstruct, quit, toggleLog, skip };
} }
); );

View File

@ -3,7 +3,7 @@ const preact = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const actions = require('../actions'); const actions = require('../actions');
const { STATS, eventClasses, getCombatText, crypAvatar } = require('../utils'); const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils');
const { animationDivs } = require('../animations'); const { animationDivs } = require('../animations');
const SkillBtn = require('./skill.btn'); const SkillBtn = require('./skill.btn');
@ -18,16 +18,16 @@ const addState = connect(
activeSkill, activeSkill,
} = state; } = state;
function selectSkillTarget(targetCrypId) { function selectSkillTarget(targetConstructId) {
if (activeSkill) { if (activeSkill) {
return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill); return ws.sendGameSkill(game.id, activeSkill.constructId, targetConstructId, activeSkill.skill);
} }
return false; return false;
} }
// intercept self casting skills // intercept self casting skills
if (activeSkill && activeSkill.skill.self_targeting) { if (activeSkill && activeSkill.skill.self_targeting) {
ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill); ws.sendGameSkill(game.id, activeSkill.constructId, null, activeSkill.skill.skill);
} }
return { return {
@ -40,48 +40,48 @@ const addState = connect(
}, },
); );
function GameCryp(props) { function GameConstruct(props) {
const { const {
game, game,
account, account,
cryp, construct,
resolution, resolution,
activeSkill, activeSkill,
setActiveCryp, setActiveConstruct,
selectSkillTarget, selectSkillTarget,
} = props; } = props;
const ko = cryp.green_life.value === 0 ? 'ko' : ''; const ko = construct.green_life.value === 0 ? 'ko' : '';
const classes = eventClasses(resolution, cryp); const classes = eventClasses(resolution, construct);
const skills = range(0, 3) const skills = range(0, 3)
.map(i => <SkillBtn key={i} cryp={cryp} i={i} />); .map(i => <SkillBtn key={i} construct={construct} i={i} />);
const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => { const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => {
// i've seen this happen ;/ // i've seen this happen ;/
if (cryp[s.stat].value < 0) console.warn(cryp); if (construct[s.stat].value < 0) console.warn(construct);
return <figure key={j} alt={s.stat}> return <figure key={j} alt={s.stat}>
{s.svg(`stat-icon ${s.colour}`)} {s.svg(`stat-icon ${s.colour}`)}
<figcaption>{cryp[s.stat].value} / {cryp[s.stat].max}</figcaption> <figcaption>{construct[s.stat].value} / {construct[s.stat].max}</figcaption>
</figure> </figure>
}); });
const [combatText, combatClass] = getCombatText(cryp, resolution); const [combatText, combatClass] = getCombatText(construct, resolution);
const combatTextClass = `combat-text ${combatClass}`; const combatTextClass = `combat-text ${combatClass}`;
const combatTextEl = combatText const combatTextEl = combatText
? <div className={combatTextClass}>{combatText}</div> ? <div className={combatTextClass}>{combatText}</div>
: null; : null;
const effects = cryp.effects.length const effects = construct.effects.length
? cryp.effects.map(c => <div key={c.effect}>{c.effect} - {c.duration}T</div>) ? construct.effects.map(c => <div key={c.effect}>{c.effect} - {c.duration}T</div>)
: <div>&nbsp;</div>; : <div>&nbsp;</div>;
const playerTeam = game.players.find(t => t.id === account.id); const playerTeam = game.players.find(t => t.id === account.id);
const playerTeamIds = playerTeam.cryps.map(c => c.id); const playerTeamIds = playerTeam.constructs.map(c => c.id);
const targeting = game.stack const targeting = game.stack
.filter(s => playerTeamIds.includes(s.source_cryp_id) && s.target_cryp_id === cryp.id) .filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id)
.map((s, i) => <h3 key={i}>{`< ${s.skill}`}</h3>); .map((s, i) => <h3 key={i}>{`< ${s.skill}`}</h3>);
const anim = ( const anim = (
@ -93,9 +93,9 @@ function GameCryp(props) {
return ( return (
<div <div
style={ activeSkill ? { cursor: 'pointer' } : {}} style={ activeSkill ? { cursor: 'pointer' } : {}}
className={`game-cryp ${ko} ${classes}`} > className={`game-construct ${ko} ${classes}`} >
<h3 className="name"> <h3 className="name">
{cryp.name} {construct.name}
</h3> </h3>
<div className="skills"> <div className="skills">
{skills} {skills}
@ -105,8 +105,8 @@ function GameCryp(props) {
</div> </div>
<figure <figure
className="img" className="img"
onClick={() => selectSkillTarget(cryp.id)} > onClick={() => selectSkillTarget(construct.id)} >
{crypAvatar(cryp.name, cryp.id)} {constructAvatar(construct.name, construct.id)}
{combatTextEl} {combatTextEl}
{anim} {anim}
</figure> </figure>
@ -120,4 +120,4 @@ function GameCryp(props) {
); );
} }
module.exports = addState(GameCryp); module.exports = addState(GameConstruct);

View File

@ -23,7 +23,7 @@ function renderHeader(args) {
return ( return (
<header> <header>
<h1 className="header-title"> <h1 className="header-title">
cryps.gg mnml.gg
</h1> </h1>
{accountStatus} {accountStatus}
</header> </header>

View File

@ -27,10 +27,10 @@ function Info(args) {
let red = 0; let red = 0;
let blue = 0; let blue = 0;
let green = 0; let green = 0;
player.cryps.forEach(cryp => { player.constructs.forEach(construct => {
red += cryp.colours.red; red += construct.colours.red;
blue += cryp.colours.blue; blue += construct.colours.blue;
green += cryp.colours.green; green += construct.colours.green;
}); });
const teamColours = { red, blue, green }; const teamColours = { red, blue, green };

View File

@ -3,7 +3,7 @@ const { connect } = require('react-redux');
const Vbox = require('./vbox.component'); const Vbox = require('./vbox.component');
const InfoContainer = require('./info.container'); const InfoContainer = require('./info.container');
const InstanceCrypsContainer = require('./instance.cryps'); const InstanceConstructsContainer = require('./instance.constructs');
const EquipmentContainer = require('./instance.equip'); const EquipmentContainer = require('./instance.equip');
const actions = require('../actions'); const actions = require('../actions');
@ -137,7 +137,7 @@ function Instance(args) {
<Vbox /> <Vbox />
<InfoContainer /> <InfoContainer />
<EquipmentContainer /> <EquipmentContainer />
<InstanceCrypsContainer /> <InstanceConstructsContainer />
</main> </main>
); );
} }

View File

@ -6,9 +6,9 @@ const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, team } = state; const { ws, team } = state;
function sendInstanceNew(sCryps, name, players) { function sendInstanceNew(sConstructs, name, players) {
if (sCryps.length) { if (sConstructs.length) {
return ws.sendInstanceNew(sCryps, name, players); return ws.sendInstanceNew(sConstructs, name, players);
} }
return false; return false;
} }

View File

@ -3,24 +3,24 @@ const preact = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const shapes = require('./shapes'); const shapes = require('./shapes');
const { SPECS, STATS, instanceCryp } = require('../utils'); const { SPECS, STATS, instanceConstruct } = require('../utils');
const actions = require('../actions'); const actions = require('../actions');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, instance, account, itemInfo, itemEquip, activeCryp } = state; const { ws, instance, account, itemInfo, itemEquip, activeConstruct } = state;
const player = instance.players.find(p => p.id === account.id); const player = instance.players.find(p => p.id === account.id);
function sendInstanceReady() { function sendInstanceReady() {
return ws.sendInstanceReady(instance.id); return ws.sendInstanceReady(instance.id);
} }
function sendVboxApply(crypId, i) { function sendVboxApply(constructId, i) {
return ws.sendVboxApply(instance.id, crypId, i); return ws.sendVboxApply(instance.id, constructId, i);
} }
function sendUnequip(crypId, item) { function sendUnequip(constructId, item) {
return ws.sendVboxUnequip(instance.id, crypId, item); return ws.sendVboxUnequip(instance.id, constructId, item);
} }
return { return {
@ -31,7 +31,7 @@ const addState = connect(
sendVboxApply, sendVboxApply,
itemInfo, itemInfo,
itemEquip, itemEquip,
activeCryp, activeConstruct,
sendUnequip, sendUnequip,
}; };
}, },
@ -45,8 +45,8 @@ const addState = connect(
dispatch(actions.setInfo(item)); dispatch(actions.setInfo(item));
} }
function setActiveCryp(value) { function setActiveConstruct(value) {
dispatch(actions.setActiveCryp(value)); dispatch(actions.setActiveConstruct(value));
} }
function clearInfo() { function clearInfo() {
@ -61,19 +61,19 @@ const addState = connect(
return dispatch(actions.setItemUnequip(v)); return dispatch(actions.setItemUnequip(v));
} }
return { quit, clearInfo, setInfo, setActiveCryp, setItemUnequip, setItemEquip }; return { quit, clearInfo, setInfo, setActiveConstruct, setItemUnequip, setItemEquip };
} }
); );
function Cryp(props) { function Construct(props) {
const { const {
activeCryp, activeConstruct,
itemEquip, itemEquip,
cryp, construct,
player, player,
sendVboxApply, sendVboxApply,
setActiveCryp, setActiveConstruct,
setItemUnequip, setItemUnequip,
setItemEquip, setItemEquip,
itemInfo, itemInfo,
@ -84,9 +84,9 @@ function Cryp(props) {
function onClick(e) { function onClick(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
if (itemEquip !== null) sendVboxApply(cryp.id, itemEquip); if (itemEquip !== null) sendVboxApply(construct.id, itemEquip);
setItemEquip(null); setItemEquip(null);
return setActiveCryp(cryp); return setActiveConstruct(construct);
} }
function hoverInfo(e, info) { function hoverInfo(e, info) {
@ -100,7 +100,7 @@ function Cryp(props) {
const specList = itemInfo.items.filter(v => v.spec).map(v => v.item); const specList = itemInfo.items.filter(v => v.spec).map(v => v.item);
const skills = range(0, 3).map(i => { const skills = range(0, 3).map(i => {
const skill = cryp.skills[i]; const skill = construct.skills[i];
const s = skill const s = skill
? skill.skill ? skill.skill
: (<span className="gray">+</span>); : (<span className="gray">+</span>);
@ -108,15 +108,15 @@ function Cryp(props) {
function skillClick(e) { function skillClick(e) {
if (!skill) return false; if (!skill) return false;
setItemUnequip(skill.skill); setItemUnequip(skill.skill);
setActiveCryp(cryp); setActiveConstruct(construct);
e.stopPropagation(); e.stopPropagation();
return true; return true;
} }
function skillDblClick(e) { function skillDblClick(e) {
if (!skill) return false; if (!skill) return false;
sendUnequip(cryp.id, skill.skill); sendUnequip(construct.id, skill.skill);
setActiveCryp(null); setActiveConstruct(null);
setItemUnequip(null); setItemUnequip(null);
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
@ -140,7 +140,7 @@ function Cryp(props) {
}); });
const specs = range(0, 6).map(i => { const specs = range(0, 6).map(i => {
const s = cryp.specs[i]; const s = construct.specs[i];
if (!s) { if (!s) {
const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray'; const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray';
@ -155,12 +155,12 @@ function Cryp(props) {
function specClick(e) { function specClick(e) {
e.stopPropagation(); e.stopPropagation();
setItemUnequip(s); setItemUnequip(s);
setActiveCryp(cryp); setActiveConstruct(construct);
} }
function specDblClick(e) { function specDblClick(e) {
sendUnequip(cryp.id, s); sendUnequip(construct.id, s);
setActiveCryp(null); setActiveConstruct(null);
setItemUnequip(null); setItemUnequip(null);
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
@ -183,14 +183,14 @@ function Cryp(props) {
const stats = Object.values(STATS).map(s => ( const stats = Object.values(STATS).map(s => (
<figure key={s.stat} alt={s.stat} className={s.stat}> <figure key={s.stat} alt={s.stat} className={s.stat}>
{s.svg(`stat-icon ${s.colour} stat`)} {s.svg(`stat-icon ${s.colour} stat`)}
<figcaption>{cryp[s.stat].value}</figcaption> <figcaption>{construct[s.stat].value}</figcaption>
</figure> </figure>
)); ));
const activeId = activeCryp ? activeCryp.id : false; const activeId = activeConstruct ? activeConstruct.id : false;
const crypClass = activeId === cryp.id ? 'instance-cryp-active' : 'instance-cryp'; const constructClass = activeId === construct.id ? 'instance-construct-active' : 'instance-construct';
// const cTotal = cryp.colours.red + cryp.colours.blue + cryp.colours.green; // const cTotal = construct.colours.red + construct.colours.blue + construct.colours.green;
// const colours = mapValues(cryp.colours, c => { // const colours = mapValues(construct.colours, c => {
// if (cTotal === 0) return 245; // if (cTotal === 0) return 245;
// return Math.floor(c / cTotal * 255); // return Math.floor(c / cTotal * 255);
// }); // });
@ -204,13 +204,13 @@ function Cryp(props) {
// const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` }; // const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` };
return ( return (
<div key={cryp.id} className={crypClass} onClick={onClick} > <div key={construct.id} className={constructClass} onClick={onClick} >
{instanceCryp(cryp.name, cryp.id)} {instanceConstruct(construct.name, construct.id)}
<h2 className="name" >{cryp.name}</h2> <h2 className="name" >{construct.name}</h2>
<div className="skills" onMouseOver={e => hoverInfo(e, 'crypSkills')} > <div className="skills" onMouseOver={e => hoverInfo(e, 'constructSkills')} >
{skills} {skills}
</div> </div>
<div className="specs" onMouseOver={e => hoverInfo(e, 'crypSpecs')} > <div className="specs" onMouseOver={e => hoverInfo(e, 'constructSpecs')} >
{specs} {specs}
</div> </div>
<div className="stats"> <div className="stats">
@ -231,15 +231,15 @@ function Cryp(props) {
); );
} }
function InstanceCryps(props) { function InstanceConstructs(props) {
const { const {
activeCryp, activeConstruct,
itemEquip, itemEquip,
player, player,
instance, instance,
// clearInfo, // clearInfo,
setInfo, setInfo,
setActiveCryp, setActiveConstruct,
sendVboxApply, sendVboxApply,
itemInfo, itemInfo,
@ -252,27 +252,27 @@ function InstanceCryps(props) {
if (!player) return false; if (!player) return false;
if (instance.phase === 'Lobby') return false; if (instance.phase === 'Lobby') return false;
const cryps = player.cryps.map((c, i) => Cryp({ const constructs = player.constructs.map((c, i) => Construct({
cryp: c, construct: c,
activeCryp, activeConstruct,
itemEquip, itemEquip,
setItemUnequip, setItemUnequip,
setItemEquip, setItemEquip,
player, player,
sendVboxApply, sendVboxApply,
setInfo, setInfo,
setActiveCryp, setActiveConstruct,
itemInfo, itemInfo,
setVboxHighlight, setVboxHighlight,
sendUnequip, sendUnequip,
})); }));
const classes = `cryp-list`; const classes = `construct-list`;
return ( return (
<div className={classes} onClick={() => setActiveCryp(null)}> <div className={classes} onClick={() => setActiveConstruct(null)}>
{cryps} {constructs}
</div> </div>
); );
} }
module.exports = addState(InstanceCryps); module.exports = addState(InstanceConstructs);

View File

@ -8,14 +8,14 @@ const { convertItem, SPECS } = require('./../utils');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { account, activeCryp, itemInfo, info, ws, instance, itemUnequip } = state; const { account, activeConstruct, itemInfo, info, ws, instance, itemUnequip } = state;
const player = instance.players.find(p => p.id === account.id); const player = instance.players.find(p => p.id === account.id);
function sendUnequip(crypId, item) { function sendUnequip(constructId, item) {
return ws.sendVboxUnequip(instance.id, crypId, item); return ws.sendVboxUnequip(instance.id, constructId, item);
} }
return { player, itemInfo, instance, info, sendUnequip, activeCryp, itemUnequip }; return { player, itemInfo, instance, info, sendUnequip, activeConstruct, itemUnequip };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
@ -48,7 +48,7 @@ function Equipment(props) {
itemUnequip, itemUnequip,
setItemEquip, setItemEquip,
setItemUnequip, setItemUnequip,
activeCryp, activeConstruct,
itemInfo, itemInfo,
sendUnequip, sendUnequip,
@ -65,7 +65,7 @@ function Equipment(props) {
const isSpec = fullInfo && fullInfo.spec; const isSpec = fullInfo && fullInfo.spec;
function skillClick(e, i) { function skillClick(e, i) {
if (itemUnequip && activeCryp) return false; if (itemUnequip && activeConstruct) return false;
const value = vbox.bound[i]; const value = vbox.bound[i];
setItemEquip(i); setItemEquip(i);
return false; return false;
@ -74,9 +74,9 @@ function Equipment(props) {
function unequipClick(e) { function unequipClick(e) {
e.stopPropagation(); e.stopPropagation();
if (!itemUnequip) return false; if (!itemUnequip) return false;
if (!activeCryp) return false; if (!activeConstruct) return false;
setItemUnequip(null); setItemUnequip(null);
return sendUnequip(activeCryp.id, itemUnequip); return sendUnequip(activeConstruct.id, itemUnequip);
} }
function hoverInfo(e, info) { function hoverInfo(e, info) {

View File

@ -7,7 +7,7 @@ const InstanceCreateForm = require('./instance.create.form');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, cryps, team, instances, account } = state; const { ws, constructs, team, instances, account } = state;
function sendInstanceJoin(instance) { function sendInstanceJoin(instance) {
if (team.length) { if (team.length) {
@ -26,7 +26,7 @@ const addState = connect(
return { return {
account, account,
cryps, constructs,
team, team,
sendInstanceJoin, sendInstanceJoin,
sendInstanceState, sendInstanceState,

View File

@ -3,7 +3,7 @@ const range = require('lodash/range');
const { NULL_UUID } = require('./../utils'); const { NULL_UUID } = require('./../utils');
const { stringSort, crypAvatar } = require('./../utils'); const { stringSort, constructAvatar } = require('./../utils');
const SpawnButton = require('./spawn.button'); const SpawnButton = require('./spawn.button');
const InstanceCreateForm = require('./instance.create.form'); const InstanceCreateForm = require('./instance.create.form');
@ -19,14 +19,14 @@ const COLOURS = [
function Menu(args) { function Menu(args) {
const { const {
account, account,
cryps, constructs,
team, team,
setTeam, setTeam,
sendInstanceState, sendInstanceState,
sendPlayerMmCrypsSet, sendPlayerMmConstructsSet,
sendInstanceJoin, sendInstanceJoin,
sendInstanceList, sendInstanceList,
sendCrypSpawn, sendConstructSpawn,
instances, instances,
} = args; } = args;
@ -61,7 +61,7 @@ function Menu(args) {
// <button // <button
// className={'menu-instance-btn left'} // className={'menu-instance-btn left'}
// disabled={instanceJoinHidden} // disabled={instanceJoinHidden}
// onClick={() => sendPlayerMmCrypsSet()}> // onClick={() => sendPlayerMmConstructsSet()}>
// Set Matchmaking Team // Set Matchmaking Team
// </button> // </button>
// ); // );
@ -88,12 +88,12 @@ function Menu(args) {
); );
} }
function crypList() { function constructList() {
if (!cryps) return <div></div>; if (!constructs) return <div></div>;
// redux limitation + suggested workaround // redux limitation + suggested workaround
// so much for dumb components // so much for dumb components
function selectCryp(id) { function selectConstruct(id) {
// remove // remove
const i = team.findIndex(sid => sid === id); const i = team.findIndex(sid => sid === id);
if (i > -1) { if (i > -1) {
@ -108,37 +108,37 @@ function Menu(args) {
return setTeam(team); return setTeam(team);
} }
const crypPanels = cryps.sort(idSort).map(cryp => { const constructPanels = constructs.sort(idSort).map(construct => {
const colour = team.indexOf(cryp.id); const colour = team.indexOf(construct.id);
const selected = colour > -1; const selected = colour > -1;
const borderColour = selected ? COLOURS[colour] : '#000000'; const borderColour = selected ? COLOURS[colour] : '#000000';
return ( return (
<div <div
key={cryp.id} key={construct.id}
className="menu-cryp-ctr"> className="menu-construct-ctr">
<div <div
className="menu-cryp" className="menu-construct"
style={ { 'border-color': borderColour || 'whitesmoke' } } style={ { 'border-color': borderColour || 'whitesmoke' } }
onClick={() => selectCryp(cryp.id)} > onClick={() => selectConstruct(construct.id)} >
{crypAvatar(cryp.name)} {constructAvatar(construct.name)}
<h2>{cryp.name}</h2> <h2>{construct.name}</h2>
</div> </div>
</div> </div>
); );
}); });
const spawnButtonsNum = cryps.length < 3 const spawnButtonsNum = constructs.length < 3
? (3 - cryps.length) ? (3 - constructs.length)
: 1; : 1;
const spawnButtons = range(spawnButtonsNum) const spawnButtons = range(spawnButtonsNum)
.map(i => <SpawnButton key={i} i={i} spawn={name => sendCrypSpawn(name)} />); .map(i => <SpawnButton key={i} i={i} spawn={name => sendConstructSpawn(name)} />);
return ( return (
<div className="menu-cryps"> <div className="menu-constructs">
{crypPanels} {constructPanels}
{spawnButtons} {spawnButtons}
</div> </div>
); );

View File

@ -5,7 +5,7 @@ const actions = require('./../actions');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, cryps, team, instances, account } = state; const { ws, constructs, team, instances, account } = state;
function sendInstanceJoin(instance) { function sendInstanceJoin(instance) {
if (team.length) { if (team.length) {
@ -14,15 +14,15 @@ const addState = connect(
return false; return false;
} }
function sendPlayerMmCrypsSet() { function sendPlayerMmConstructsSet() {
if (team.length) { if (team.length) {
return ws.sendPlayerMmCrypsSet(team); return ws.sendPlayerMmConstructsSet(team);
} }
return false; return false;
} }
function sendCrypSpawn(name) { function sendConstructSpawn(name) {
return ws.sendCrypSpawn(name); return ws.sendConstructSpawn(name);
} }
function sendInstanceState(instance) { function sendInstanceState(instance) {
@ -35,20 +35,20 @@ const addState = connect(
return { return {
account, account,
cryps, constructs,
team, team,
sendInstanceJoin, sendInstanceJoin,
sendInstanceState, sendInstanceState,
sendInstanceList, sendInstanceList,
sendCrypSpawn, sendConstructSpawn,
sendPlayerMmCrypsSet, sendPlayerMmConstructsSet,
instances, instances,
}; };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
function setTeam(crypIds) { function setTeam(constructIds) {
dispatch(actions.setTeam(crypIds)); dispatch(actions.setTeam(constructIds));
} }
return { return {

View File

@ -15,7 +15,7 @@ const addState = connect(
account, account,
instances, instances,
team, team,
cryps, constructs,
game, game,
} = state; } = state;
@ -27,7 +27,7 @@ const addState = connect(
account, account,
instances, instances,
team, team,
cryps, constructs,
game, game,
sendInstanceState, sendInstanceState,
}; };
@ -60,7 +60,7 @@ function Nav(args) {
account, account,
sendInstanceState, sendInstanceState,
team, team,
cryps, constructs,
instances, instances,
game, game,
@ -81,8 +81,8 @@ function Nav(args) {
const teamElements = team.map((c, i) => { const teamElements = team.map((c, i) => {
if (c) { if (c) {
const cryp = cryps.find(f => f.id === c); const construct = constructs.find(f => f.id === c);
return <button key={c} onClick={() => navTo('team')}>{cryp.name}</button>; return <button key={c} onClick={() => navTo('team')}>{construct.name}</button>;
} }
return <button key={i} onClick={() => navTo('team')}>+</button>; return <button key={i} onClick={() => navTo('team')}>+</button>;
}); });

View File

@ -17,8 +17,8 @@ const addState = connect(
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
function setActiveSkill(crypId, skill) { function setActiveSkill(constructId, skill) {
dispatch(actions.setActiveSkill(crypId, skill)); dispatch(actions.setActiveSkill(constructId, skill));
} }
return { setActiveSkill }; return { setActiveSkill };
@ -28,7 +28,7 @@ const addState = connect(
function Skill(props) { function Skill(props) {
const { const {
cryp, construct,
game, game,
i, i,
mobile, mobile,
@ -36,14 +36,14 @@ function Skill(props) {
setActiveSkill, setActiveSkill,
} = props; } = props;
const s = cryp.skills[i]; const s = construct.skills[i];
const ko = cryp.green_life.value === 0 ? 'ko' : ''; const ko = construct.green_life.value === 0 ? 'ko' : '';
if (!s) { if (!s) {
return ( return (
<button <button
disabled='true' disabled='true'
className='cryp-skill-btn disabled'> className='construct-skill-btn disabled'>
</button> </button>
); );
} }
@ -52,25 +52,25 @@ function Skill(props) {
? 'top' ? 'top'
: ''; : '';
const cdText = cryp.skills[i].cd > 0 const cdText = construct.skills[i].cd > 0
? `- ${s.cd}T` ? `- ${s.cd}T`
: ''; : '';
const highlight = activeSkill const highlight = activeSkill
? activeSkill.crypId === cryp.id && activeSkill.skill === s.skill ? activeSkill.constructId === construct.id && activeSkill.skill === s.skill
: false; : false;
function onClick(e) { function onClick(e) {
e.stopPropagation(); e.stopPropagation();
return setActiveSkill(cryp.id, s.skill); return setActiveSkill(construct.id, s.skill);
} }
const targeting = game.stack.some(stack => stack.source_cryp_id === cryp.id && stack.skill === s.skill); const targeting = game.stack.some(stack => stack.source_construct_id === construct.id && stack.skill === s.skill);
return ( return (
<button <button
disabled={!!cdText || ko} disabled={!!cdText || ko}
className={`cryp-skill-btn ${side} ${(targeting || highlight) ? 'active' : ''}`} className={`construct-skill-btn ${side} ${(targeting || highlight) ? 'active' : ''}`}
type="submit" type="submit"
onClick={onClick}> onClick={onClick}>
{s.skill} {cdText} {s.skill} {cdText}

View File

@ -31,9 +31,9 @@ class SpawnButton extends Component {
return ( return (
<div <div
key={this.props.i} key={this.props.i}
className="menu-cryp-ctr spawn-btn"> className="menu-construct-ctr spawn-btn">
<div <div
className="menu-cryp" className="menu-construct"
onClick={() => this.enable()} > onClick={() => this.enable()} >
<h2>+</h2> <h2>+</h2>
<input <input

View File

@ -11,17 +11,17 @@ function TargetSvg(args) {
const playerTeam = game.players.find(t => t.id === account.id); const playerTeam = game.players.find(t => t.id === account.id);
const otherTeam = game.players.find(t => t.id !== account.id); const otherTeam = game.players.find(t => t.id !== account.id);
const playerTeamIds = playerTeam.cryps.map(c => c.id); const playerTeamIds = playerTeam.constructs.map(c => c.id);
const outgoing = game.stack.filter(stack => playerTeamIds.includes(stack.source_cryp_id)); const outgoing = game.stack.filter(stack => playerTeamIds.includes(stack.source_construct_id));
function getPath(cast) { function getPath(cast) {
const source = playerTeam.cryps.findIndex(c => c.id === cast.source_cryp_id); const source = playerTeam.constructs.findIndex(c => c.id === cast.source_construct_id);
const defensive = playerTeamIds.includes(cast.target_cryp_id); const defensive = playerTeamIds.includes(cast.target_construct_id);
const target = defensive const target = defensive
? playerTeam.cryps.findIndex(c => c.id === cast.target_cryp_id) ? playerTeam.constructs.findIndex(c => c.id === cast.target_construct_id)
: otherTeam.cryps.findIndex(c => c.id === cast.target_cryp_id); : otherTeam.constructs.findIndex(c => c.id === cast.target_construct_id);
const skillIndex = playerTeam.cryps[source].skills.findIndex(s => s.skill === cast.skill); const skillIndex = playerTeam.constructs[source].skills.findIndex(s => s.skill === cast.skill);
const skillOffset = (100 * skillIndex) + 50; const skillOffset = (100 * skillIndex) + 50;
const sourceY = 0; const sourceY = 0;

View File

@ -4,7 +4,7 @@ const range = require('lodash/range');
const actions = require('./../actions'); const actions = require('./../actions');
const { NULL_UUID } = require('./../utils'); const { NULL_UUID } = require('./../utils');
const { stringSort, crypAvatar } = require('./../utils'); const { stringSort, constructAvatar } = require('./../utils');
const SpawnButton = require('./spawn.button'); const SpawnButton = require('./spawn.button');
const idSort = stringSort('id'); const idSort = stringSort('id');
@ -17,23 +17,23 @@ const COLOURS = [
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, cryps, team, account } = state; const { ws, constructs, team, account } = state;
function sendCrypSpawn(name) { function sendConstructSpawn(name) {
return ws.sendCrypSpawn(name); return ws.sendConstructSpawn(name);
} }
return { return {
account, account,
cryps, constructs,
team, team,
sendCrypSpawn, sendConstructSpawn,
}; };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
function setTeam(crypIds) { function setTeam(constructIds) {
dispatch(actions.setTeam(crypIds)); dispatch(actions.setTeam(constructIds));
} }
function navToList() { function navToList() {
@ -53,19 +53,19 @@ const addState = connect(
function Team(args) { function Team(args) {
const { const {
account, account,
cryps, constructs,
team, team,
setTeam, setTeam,
sendCrypSpawn, sendConstructSpawn,
navToList, navToList,
} = args; } = args;
if (!cryps) return <div></div>; if (!constructs) return <div></div>;
// redux limitation + suggested workaround // redux limitation + suggested workaround
// so much for dumb components // so much for dumb components
function selectCryp(id) { function selectConstruct(id) {
// remove // remove
const i = team.findIndex(sid => sid === id); const i = team.findIndex(sid => sid === id);
if (i > -1) { if (i > -1) {
@ -80,31 +80,31 @@ function Team(args) {
return setTeam(team); return setTeam(team);
} }
const crypPanels = cryps.sort(idSort).map(cryp => { const constructPanels = constructs.sort(idSort).map(construct => {
const colour = team.indexOf(cryp.id); const colour = team.indexOf(construct.id);
const selected = colour > -1; const selected = colour > -1;
const borderColour = selected ? COLOURS[colour] : '#000000'; const borderColour = selected ? COLOURS[colour] : '#000000';
return ( return (
<div <div
key={cryp.id} key={construct.id}
className="menu-cryp-ctr"> className="menu-construct-ctr">
<div <div
className="menu-cryp" className="menu-construct"
style={ { 'border-color': borderColour || 'whitesmoke' } } style={ { 'border-color': borderColour || 'whitesmoke' } }
onClick={() => selectCryp(cryp.id)} > onClick={() => selectConstruct(construct.id)} >
{crypAvatar(cryp.name, cryp.id)} {constructAvatar(construct.name, construct.id)}
<h2>{cryp.name}</h2> <h2>{construct.name}</h2>
</div> </div>
</div> </div>
); );
}); });
const spawnButtonsNum = (3 - cryps.length % 3); const spawnButtonsNum = (3 - constructs.length % 3);
const spawnButtons = range(spawnButtonsNum) const spawnButtons = range(spawnButtonsNum)
.map(i => <SpawnButton key={i} i={i} spawn={name => sendCrypSpawn(name)} />); .map(i => <SpawnButton key={i} i={i} spawn={name => sendConstructSpawn(name)} />);
const header = ( const header = (
@ -119,10 +119,10 @@ function Team(args) {
); );
return ( return (
<main className="menu-cryps"> <main className="menu-constructs">
{header} {header}
<div className="list"> <div className="list">
{crypPanels} {constructPanels}
{spawnButtons} {spawnButtons}
</div> </div>
</main> </main>

View File

@ -45,19 +45,19 @@ module.exports = {
}, },
equipSkills: { equipSkills: {
item: 'QUICK ACCESS - SKILLS', item: 'QUICK ACCESS - SKILLS',
description: 'Click to select \nClick target CRYP to equip', description: 'Click to select \nClick target CONSTRUCT to equip',
}, },
equipSpecs: { equipSpecs: {
item: 'QUICK ACCESS - SPECS', item: 'QUICK ACCESS - SPECS',
description: 'Click to select \nClick target CRYP to equip', description: 'Click to select \nClick target CONSTRUCT to equip',
}, },
crypSkills: { constructSkills: {
item: 'SKILLS', item: 'SKILLS',
description: 'Skills are used by Cryps in-game.\nClick a SKILL above and select a CRYP to equip.\nDouble-click to unequip.', description: 'Skills are used by Constructs in-game.\nClick a SKILL above and select a CONSTRUCT to equip.\nDouble-click to unequip.',
}, },
crypSpecs: { constructSpecs: {
item: 'SPECS', item: 'SPECS',
description: 'SPECS increase the STATS of a CRYP.\nSPECS have increased effect once they reach a THRESHOLD across your whole team.\nClick a SPEC above and select a CRYP to equip.\nDouble-click to unequip.', description: 'SPECS increase the STATS of a CONSTRUCT.\nSPECS have increased effect once they reach a THRESHOLD across your whole team.\nClick a SPEC above and select a CONSTRUCT to equip.\nDouble-click to unequip.',
}, },
}, },

View File

@ -3,13 +3,13 @@ const eachSeries = require('async/eachSeries');
const actions = require('./actions'); const actions = require('./actions');
const { TIMES } = require('./constants'); const { TIMES } = require('./constants');
const { getCombatSequence, resoCrypHealth } = require('./utils'); const { getCombatSequence, resoConstructHealth } = require('./utils');
function registerEvents(store) { function registerEvents(store) {
// timeout handlers // timeout handlers
store.subscribe(() => { store.subscribe(() => {
const { game, instance, cryps, ws } = store.getState(); const { game, instance, constructs, ws } = store.getState();
if (!game) ws.clearGameStateTimeout(); if (!game) ws.clearGameStateTimeout();
if (!instance) ws.clearInstanceStateTimeout(); if (!instance) ws.clearInstanceStateTimeout();
@ -19,12 +19,12 @@ function registerEvents(store) {
store.dispatch(actions.setPing(ping)); store.dispatch(actions.setPing(ping));
} }
function setCryps(cryps) { function setConstructs(constructs) {
console.log('EVENT ->', 'cryps', cryps); console.log('EVENT ->', 'constructs', constructs);
} }
function setCrypList(cryps) { function setConstructList(constructs) {
store.dispatch(actions.setCryps(cryps)); store.dispatch(actions.setConstructs(constructs));
} }
function setWs(ws) { function setWs(ws) {
@ -50,8 +50,8 @@ function registerEvents(store) {
const stagedR = Object.create(r); const stagedR = Object.create(r);
stagedR.stage = stage; stagedR.stage = stage;
// Apply damage for each cryp // Apply damage for each construct
if (stage === 'POST_SKILL') resoCrypHealth(stagedR, currentGame); if (stage === 'POST_SKILL') resoConstructHealth(stagedR, currentGame);
store.dispatch(actions.setResolution(stagedR)); store.dispatch(actions.setResolution(stagedR));
return setTimeout(sCb, TIMES[stage]); return setTimeout(sCb, TIMES[stage]);
@ -98,7 +98,7 @@ function registerEvents(store) {
function clearInfo() { function clearInfo() {
store.dispatch(actions.setInfo(null)); store.dispatch(actions.setInfo(null));
store.dispatch(actions.setActiveCryp(null)); store.dispatch(actions.setActiveConstruct(null));
console.log('event clear item'); console.log('event clear item');
} }
@ -132,8 +132,8 @@ function registerEvents(store) {
console.log('EVENT ->', 'gameList', gameList); console.log('EVENT ->', 'gameList', gameList);
} }
function setCrypStatusUpdate(id, skill, target) { function setConstructStatusUpdate(id, skill, target) {
console.log('EVENT ->', 'crypStatusUpdate', { id, skill, target }); console.log('EVENT ->', 'constructStatusUpdate', { id, skill, target });
} }
function setItemInfo(v) { function setItemInfo(v) {
@ -142,22 +142,22 @@ function registerEvents(store) {
// events.on('SET_PLAYER', setInstance); // events.on('SET_PLAYER', setInstance);
// events.on('SEND_SKILL', function skillActive(gameId, crypId, targetCrypId, skill) { // events.on('SEND_SKILL', function skillActive(gameId, constructId, targetConstructId, skill) {
// ws.sendGameSkill(gameId, crypId, targetCrypId, skill); // ws.sendGameSkill(gameId, constructId, targetConstructId, skill);
// setCrypStatusUpdate(crypId, skill, targetCrypId); // setConstructStatusUpdate(constructId, skill, targetConstructId);
// }); // });
// events.on('CRYP_ACTIVE', function crypActiveCb(cryp) { // events.on('CONSTRUCT_ACTIVE', function constructActiveCb(construct) {
// for (let i = 0; i < cryps.length; i += 1) { // for (let i = 0; i < constructs.length; i += 1) {
// if (cryps[i].id === cryp.id) cryps[i].active = !cryps[i].active; // if (constructs[i].id === construct.id) constructs[i].active = !constructs[i].active;
// } // }
// return setCryps(cryps); // return setConstructs(constructs);
// }); // });
const errMessages = { const errMessages = {
select_cryps: 'Select your cryps before battle using the numbered buttons next to the cryp avatar', select_constructs: 'Select your constructs before battle using the numbered buttons next to the construct avatar',
complete_nodes: 'You need to complete the previously connected nodes first', complete_nodes: 'You need to complete the previously connected nodes first',
max_skills: 'Your cryp can only learn a maximum of 4 skills', max_skills: 'Your construct can only learn a maximum of 4 skills',
}; };
@ -185,8 +185,8 @@ function registerEvents(store) {
setAccount, setAccount,
setActiveSkill, setActiveSkill,
setActiveItem, setActiveItem,
setCryps, setConstructs,
setCrypList, setConstructList,
setGame, setGame,
clearInfo, clearInfo,
setMenu, setMenu,

View File

@ -7,7 +7,7 @@ function setupKeys(store) {
key('esc', () => store.dispatch(actions.setCombiner([null, null, null]))); key('esc', () => store.dispatch(actions.setCombiner([null, null, null])));
key('esc', () => store.dispatch(actions.setReclaiming(false))); key('esc', () => store.dispatch(actions.setReclaiming(false)));
key('esc', () => store.dispatch(actions.setActiveSkill(null))); key('esc', () => store.dispatch(actions.setActiveSkill(null)));
key('esc', () => store.dispatch(actions.setActiveCryp(null))); key('esc', () => store.dispatch(actions.setActiveConstruct(null)));
key('esc', () => store.dispatch(actions.setInfo(null))); key('esc', () => store.dispatch(actions.setInfo(null)));
key('esc', () => store.dispatch(actions.setItemEquip(null))); key('esc', () => store.dispatch(actions.setItemEquip(null)));
key('esc', () => store.dispatch(actions.setItemUnequip(null))); key('esc', () => store.dispatch(actions.setItemUnequip(null)));

View File

@ -12,11 +12,11 @@ function createReducer(defaultState, actionType) {
/* eslint-disable key-spacing */ /* eslint-disable key-spacing */
module.exports = { module.exports = {
account: createReducer(null, 'SET_ACCOUNT'), account: createReducer(null, 'SET_ACCOUNT'),
activeCryp: createReducer(null, 'SET_ACTIVE_CRYP'), activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'),
activeItem: createReducer(null, 'SET_ACTIVE_VAR'), activeItem: createReducer(null, 'SET_ACTIVE_VAR'),
activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'), activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'),
combiner: createReducer([null, null, null], 'SET_COMBINER'), combiner: createReducer([null, null, null], 'SET_COMBINER'),
cryps: createReducer([], 'SET_CRYPS'), constructs: createReducer([], 'SET_CONSTRUCTS'),
game: createReducer(null, 'SET_GAME'), game: createReducer(null, 'SET_GAME'),
info: createReducer(null, 'SET_INFO'), info: createReducer(null, 'SET_INFO'),
instance: createReducer(null, 'SET_INSTANCE'), instance: createReducer(null, 'SET_INSTANCE'),
@ -30,7 +30,7 @@ module.exports = {
resolution: createReducer(null, 'SET_RESOLUTION'), resolution: createReducer(null, 'SET_RESOLUTION'),
showLog: createReducer(false, 'SET_SHOW_LOG'), showLog: createReducer(false, 'SET_SHOW_LOG'),
skip: createReducer(false, 'SET_SKIP'), skip: createReducer(false, 'SET_SKIP'),
team: createReducer([null, null, null], 'SET_SELECTED_CRYPS'), team: createReducer([null, null, null], 'SET_SELECTED_CONSTRUCTS'),
vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'), vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'),
ws: createReducer(null, 'SET_WS'), ws: createReducer(null, 'SET_WS'),
}; };

View File

@ -1,7 +1,7 @@
const toast = require('izitoast'); const toast = require('izitoast');
const cbor = require('borc'); const cbor = require('borc');
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://cryps.gg/ws' : 'ws://localhost:40000'; const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://mnml.gg/ws' : 'ws://localhost:40000';
function errorToast(err) { function errorToast(err) {
console.error(err); console.error(err);
@ -47,8 +47,8 @@ function createSocket(events) {
send({ method: 'account_create', params: { name, password } }); send({ method: 'account_create', params: { name, password } });
} }
function sendAccountCryps() { function sendAccountConstructs() {
send({ method: 'account_cryps', params: {} }); send({ method: 'account_constructs', params: {} });
} }
function sendAccountInstances() { function sendAccountInstances() {
@ -59,8 +59,8 @@ function createSocket(events) {
send({ method: 'account_zone', params: {} }); send({ method: 'account_zone', params: {} });
} }
function sendCrypSpawn(name) { function sendConstructSpawn(name) {
send({ method: 'cryp_spawn', params: { name } }); send({ method: 'construct_spawn', params: { name } });
} }
function sendGameState(id) { function sendGameState(id) {
@ -72,11 +72,11 @@ function createSocket(events) {
} }
function sendSpecForget(id, spec) { function sendSpecForget(id, spec) {
send({ method: 'cryp_unspec', params: { id, spec } }); send({ method: 'construct_unspec', params: { id, spec } });
} }
function sendPlayerMmCrypsSet(crypIds) { function sendPlayerMmConstructsSet(constructIds) {
send({ method: 'player_mm_cryps_set', params: { cryp_ids: crypIds } }); send({ method: 'player_mm_constructs_set', params: { construct_ids: constructIds } });
} }
function sendInstanceState(instanceId) { function sendInstanceState(instanceId) {
@ -87,13 +87,13 @@ function createSocket(events) {
send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group, index } }); send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group, index } });
} }
function sendVboxApply(instanceId, crypId, index) { function sendVboxApply(instanceId, constructId, index) {
send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } }); send({ method: 'player_vbox_apply', params: { instance_id: instanceId, construct_id: constructId, index } });
events.setActiveItem(null); events.setActiveItem(null);
} }
function sendVboxUnequip(instanceId, crypId, target) { function sendVboxUnequip(instanceId, constructId, target) {
send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } }); send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, construct_id: constructId, target } });
events.clearInfo(); events.clearInfo();
} }
@ -114,18 +114,18 @@ function createSocket(events) {
send({ method: 'item_info', params: {} }); send({ method: 'item_info', params: {} });
} }
function sendGameSkill(gameId, crypId, targetCrypId, skill) { function sendGameSkill(gameId, constructId, targetConstructId, skill) {
send({ send({
method: 'game_skill', method: 'game_skill',
params: { params: {
game_id: gameId, cryp_id: crypId, target_cryp_id: targetCrypId, skill, game_id: gameId, construct_id: constructId, target_construct_id: targetConstructId, skill,
}, },
}); });
events.setActiveSkill(null); events.setActiveSkill(null);
} }
function sendGameTarget(gameId, crypId, skillId) { function sendGameTarget(gameId, constructId, skillId) {
send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } }); send({ method: 'game_target', params: { game_id: gameId, construct_id: constructId, skill_id: skillId } });
events.setActiveSkill(null); events.setActiveSkill(null);
} }
@ -133,20 +133,20 @@ function createSocket(events) {
send({ method: 'zone_create', params: {} }); send({ method: 'zone_create', params: {} });
} }
function sendZoneJoin(zoneId, nodeId, crypIds) { function sendZoneJoin(zoneId, nodeId, constructIds) {
send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, cryp_ids: crypIds } }); send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, construct_ids: constructIds } });
} }
function sendZoneClose(zoneId) { function sendZoneClose(zoneId) {
send({ method: 'zone_close', params: { zone_id: zoneId } }); send({ method: 'zone_close', params: { zone_id: zoneId } });
} }
function sendInstanceJoin(instanceId, cryps) { function sendInstanceJoin(instanceId, constructs) {
send({ method: 'instance_join', params: { instance_id: instanceId, cryp_ids: cryps } }); send({ method: 'instance_join', params: { instance_id: instanceId, construct_ids: constructs } });
} }
function sendInstanceNew(cryps, name, players) { function sendInstanceNew(constructs, name, players) {
send({ method: 'instance_new', params: { cryp_ids: cryps, name, players } }); send({ method: 'instance_new', params: { construct_ids: constructs, name, players } });
} }
function sendInstanceReady(instanceId) { function sendInstanceReady(instanceId) {
@ -167,7 +167,7 @@ function createSocket(events) {
account = login; account = login;
localStorage.setItem('account', JSON.stringify(login)); localStorage.setItem('account', JSON.stringify(login));
events.setAccount(login); events.setAccount(login);
sendAccountCryps(); sendAccountConstructs();
sendAccountInstances(); sendAccountInstances();
} }
@ -176,9 +176,9 @@ function createSocket(events) {
events.setInstanceList(playerList); events.setInstanceList(playerList);
} }
function accountCryps(response) { function accountConstructs(response) {
const [structName, cryps] = response; const [structName, constructs] = response;
events.setCrypList(cryps); events.setConstructList(constructs);
} }
function gameState(response) { function gameState(response) {
@ -197,8 +197,8 @@ function createSocket(events) {
clearTimeout(gameStateTimeout); clearTimeout(gameStateTimeout);
} }
function crypSpawn(response) { function constructSpawn(response) {
const [structName, cryp] = response; const [structName, construct] = response;
} }
function zoneState(response) { function zoneState(response) {
@ -240,11 +240,11 @@ function createSocket(events) {
// when the server sends a reply it will have one of these message types // when the server sends a reply it will have one of these message types
// this object wraps the reply types to a function // this object wraps the reply types to a function
const handlers = { const handlers = {
cryp_spawn: crypSpawn, construct_spawn: constructSpawn,
game_state: gameState, game_state: gameState,
account_login: accountLogin, account_login: accountLogin,
account_create: accountLogin, account_create: accountLogin,
account_cryps: accountCryps, account_constructs: accountConstructs,
account_instances: accountInstanceList, account_instances: accountInstanceList,
zone_create: res => console.log(res), zone_create: res => console.log(res),
zone_state: zoneState, zone_state: zoneState,
@ -264,9 +264,9 @@ function createSocket(events) {
switch (error) { switch (error) {
case 'invalid token': return logout(); case 'invalid token': return logout();
case 'no active zone': return sendZoneCreate(); case 'no active zone': return sendZoneCreate();
case 'no cryps selected': return events.errorPrompt('select_cryps'); case 'no constructs selected': return events.errorPrompt('select_constructs');
case 'node requirements not met': return events.errorPrompt('complete_nodes'); case 'node requirements not met': return events.errorPrompt('complete_nodes');
case 'cryp at max skills (4)': return events.errorPrompt('max_skills'); case 'construct at max skills (4)': return events.errorPrompt('max_skills');
default: return errorToast(error); default: return errorToast(error);
@ -303,7 +303,7 @@ function createSocket(events) {
if (account) { if (account) {
events.setAccount(account); events.setAccount(account);
sendAccountInstances(); sendAccountInstances();
sendAccountCryps(); sendAccountConstructs();
setTimeout(sendItemInfo, 2000); setTimeout(sendItemInfo, 2000);
} }
@ -338,14 +338,14 @@ function createSocket(events) {
clearInstanceStateTimeout, clearInstanceStateTimeout,
sendAccountLogin, sendAccountLogin,
sendAccountCreate, sendAccountCreate,
sendAccountCryps, sendAccountConstructs,
sendAccountInstances, sendAccountInstances,
sendAccountZone, sendAccountZone,
sendGameState, sendGameState,
sendGameReady, sendGameReady,
sendGameSkill, sendGameSkill,
sendGameTarget, sendGameTarget,
sendCrypSpawn, sendConstructSpawn,
sendSpecForget, sendSpecForget,
sendZoneCreate, sendZoneCreate,
sendZoneJoin, sendZoneJoin,
@ -354,7 +354,7 @@ function createSocket(events) {
sendInstanceReady, sendInstanceReady,
sendInstanceNew, sendInstanceNew,
sendInstanceScores, sendInstanceScores,
sendPlayerMmCrypsSet, sendPlayerMmConstructsSet,
sendInstanceState, sendInstanceState,
sendVboxAccept, sendVboxAccept,
sendVboxApply, sendVboxApply,

View File

@ -2,7 +2,7 @@
function testGame(uuid) { function testGame(uuid) {
return { return {
"id": "667ad344-dc76-40b9-bb9c-0d20f0f7f5d2", "id": "667ad344-dc76-40b9-bb9c-0d20f0f7f5d2",
"player_cryps": 3, "player_constructs": 3,
"player_num": 2, "player_num": 2,
"players": [ "players": [
{ {
@ -32,7 +32,7 @@ function testGame(uuid) {
"wins": 0, "wins": 0,
"losses": 0 "losses": 0
}, },
"cryps": [ "constructs": [
{ {
"id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b", "id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b",
"account": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1", "account": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1",
@ -295,7 +295,7 @@ function testGame(uuid) {
"wins": 0, "wins": 0,
"losses": 0 "losses": 0
}, },
"cryps": [ "constructs": [
{ {
"id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd", "id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"account": uuid, "account": uuid,
@ -543,8 +543,8 @@ function testGame(uuid) {
{ {
"id": "15ef2068-0eec-4eda-b2b2-5abe78e4ff9a", "id": "15ef2068-0eec-4eda-b2b2-5abe78e4ff9a",
"source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1", "source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1",
"source_cryp_id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b", "source_construct_id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b",
"target_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683", "target_construct_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []
@ -552,8 +552,8 @@ function testGame(uuid) {
{ {
"id": "4fbe9c95-8f40-4f65-9f0e-b77d5eb64b17", "id": "4fbe9c95-8f40-4f65-9f0e-b77d5eb64b17",
"source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1", "source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1",
"source_cryp_id": "ea302c35-d326-475c-a867-8ad5b162165a", "source_construct_id": "ea302c35-d326-475c-a867-8ad5b162165a",
"target_cryp_id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd", "target_construct_id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []
@ -561,8 +561,8 @@ function testGame(uuid) {
{ {
"id": "c2f398b8-6f5a-4fda-8c8d-b1be53819040", "id": "c2f398b8-6f5a-4fda-8c8d-b1be53819040",
"source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1", "source_player_id": "8552e0bf-340d-4fc8-b6fc-3d56b68fe2a1",
"source_cryp_id": "82e8b940-411c-42a1-8fc2-484ec7207734", "source_construct_id": "82e8b940-411c-42a1-8fc2-484ec7207734",
"target_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683", "target_construct_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []
@ -570,8 +570,8 @@ function testGame(uuid) {
{ {
"id": "6bc9c3ce-587e-4bbe-ac81-2bc536ebbce4", "id": "6bc9c3ce-587e-4bbe-ac81-2bc536ebbce4",
"source_player_id": uuid, "source_player_id": uuid,
"source_cryp_id": "5d49fe65-27f0-4372-90a3-334ef906a0f5", "source_construct_id": "5d49fe65-27f0-4372-90a3-334ef906a0f5",
"target_cryp_id": "82e8b940-411c-42a1-8fc2-484ec7207734", "target_construct_id": "82e8b940-411c-42a1-8fc2-484ec7207734",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []
@ -579,8 +579,8 @@ function testGame(uuid) {
{ {
"id": "9d2fc857-51c7-4640-a17c-a08496480830", "id": "9d2fc857-51c7-4640-a17c-a08496480830",
"source_player_id": uuid, "source_player_id": uuid,
"source_cryp_id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd", "source_construct_id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"target_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683", "target_construct_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []
@ -588,8 +588,8 @@ function testGame(uuid) {
{ {
"id": "e1bd2d77-181a-4f2d-a4f6-78c9ad3c5b3b", "id": "e1bd2d77-181a-4f2d-a4f6-78c9ad3c5b3b",
"source_player_id": uuid, "source_player_id": uuid,
"source_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683", "source_construct_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"target_cryp_id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b", "target_construct_id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b",
"skill": "Attack", "skill": "Attack",
"speed": 0, "speed": 0,
"resolutions": [] "resolutions": []

View File

@ -34,7 +34,7 @@ function testInstance(uuid) {
"wins": 12, "wins": 12,
"losses": 4 "losses": 4
}, },
"cryps": [ "constructs": [
{ {
"id": "32ffeb78-e69d-4796-ba16-624a8db678c1", "id": "32ffeb78-e69d-4796-ba16-624a8db678c1",
"account": "681626d4-1c39-4968-a159-0921cf0fe497", "account": "681626d4-1c39-4968-a159-0921cf0fe497",
@ -319,7 +319,7 @@ function testInstance(uuid) {
"wins": 13, "wins": 13,
"losses": 3 "losses": 3
}, },
"cryps": [ "constructs": [
{ {
"id": "d9bb5a7f-86d4-4075-9783-c899c91b48f4", "id": "d9bb5a7f-86d4-4075-9783-c899c91b48f4",
"account": "04e4bdbb-54d6-4d3a-9987-366520c05a04", "account": "04e4bdbb-54d6-4d3a-9987-366520c05a04",
@ -608,7 +608,7 @@ function testInstance(uuid) {
"wins": 1, "wins": 1,
"losses": 15 "losses": 15
}, },
"cryps": [ "constructs": [
{ {
"id": "4098d753-2196-46dc-98e0-bd5c86e3fbaa", "id": "4098d753-2196-46dc-98e0-bd5c86e3fbaa",
"account": "cbb7a327-1cec-464d-972c-96e4298d3941", "account": "cbb7a327-1cec-464d-972c-96e4298d3941",
@ -897,7 +897,7 @@ function testInstance(uuid) {
"wins": 4, "wins": 4,
"losses": 12 "losses": 12
}, },
"cryps": [ "constructs": [
{ {
"id": "b9c41633-73c1-4ce5-b9c6-3f18196b94d4", "id": "b9c41633-73c1-4ce5-b9c6-3f18196b94d4",
"account": "04a13f79-145f-4cd4-bb4c-9108637f4c04", "account": "04a13f79-145f-4cd4-bb4c-9108637f4c04",
@ -1186,7 +1186,7 @@ function testInstance(uuid) {
"wins": 6, "wins": 6,
"losses": 10 "losses": 10
}, },
"cryps": [ "constructs": [
{ {
"id": "c7106871-91b4-4e13-96c8-13cf95878896", "id": "c7106871-91b4-4e13-96c8-13cf95878896",
"account": "d59b2bd4-01b3-4802-9e4d-d716b9f63114", "account": "d59b2bd4-01b3-4802-9e4d-d716b9f63114",
@ -1475,7 +1475,7 @@ function testInstance(uuid) {
"wins": 6, "wins": 6,
"losses": 10 "losses": 10
}, },
"cryps": [ "constructs": [
{ {
"id": "52e54ac6-a254-4f74-aee7-0c8df4e92133", "id": "52e54ac6-a254-4f74-aee7-0c8df4e92133",
"account": "64ddef5a-0af4-480d-8ed3-24e7fc3c0761", "account": "64ddef5a-0af4-480d-8ed3-24e7fc3c0761",
@ -1764,7 +1764,7 @@ function testInstance(uuid) {
"wins": 8, "wins": 8,
"losses": 8 "losses": 8
}, },
"cryps": [ "constructs": [
{ {
"id": "13d638ba-d738-42eb-9080-e0b9c6bbccd2", "id": "13d638ba-d738-42eb-9080-e0b9c6bbccd2",
"account": "fcdfcb93-da2e-4027-a360-7bc5a6328cd1", "account": "fcdfcb93-da2e-4027-a360-7bc5a6328cd1",
@ -2053,7 +2053,7 @@ function testInstance(uuid) {
"wins": 11, "wins": 11,
"losses": 5 "losses": 5
}, },
"cryps": [ "constructs": [
{ {
"id": "363f3902-8410-4984-bde8-cb7f77dc621f", "id": "363f3902-8410-4984-bde8-cb7f77dc621f",
"account": "1f1145ad-def5-4e0e-b4f9-97310c1a58fb", "account": "1f1145ad-def5-4e0e-b4f9-97310c1a58fb",
@ -2342,7 +2342,7 @@ function testInstance(uuid) {
"wins": 9, "wins": 9,
"losses": 7 "losses": 7
}, },
"cryps": [ "constructs": [
{ {
"id": "9c490d3e-5509-439b-b197-f6fa80b8bee5", "id": "9c490d3e-5509-439b-b197-f6fa80b8bee5",
"account": "eba6a766-7a95-4dc7-95a1-00a5a203921d", "account": "eba6a766-7a95-4dc7-95a1-00a5a203921d",
@ -2631,7 +2631,7 @@ function testInstance(uuid) {
"wins": 9, "wins": 9,
"losses": 7 "losses": 7
}, },
"cryps": [ "constructs": [
{ {
"id": "104f82e0-a053-4b77-b01b-7598998d5014", "id": "104f82e0-a053-4b77-b01b-7598998d5014",
"account": "78531f40-7e44-4ac9-90ae-23f51c3dea5a", "account": "78531f40-7e44-4ac9-90ae-23f51c3dea5a",
@ -2920,7 +2920,7 @@ function testInstance(uuid) {
"wins": 12, "wins": 12,
"losses": 4 "losses": 4
}, },
"cryps": [ "constructs": [
{ {
"id": "6f1b51bd-b9ff-4269-b92e-b9d6629650f7", "id": "6f1b51bd-b9ff-4269-b92e-b9d6629650f7",
"account": "74980fc0-c0ad-4a1d-a28e-e1f6ddc6bdc2", "account": "74980fc0-c0ad-4a1d-a28e-e1f6ddc6bdc2",
@ -3209,7 +3209,7 @@ function testInstance(uuid) {
"wins": 6, "wins": 6,
"losses": 10 "losses": 10
}, },
"cryps": [ "constructs": [
{ {
"id": "55116a6e-c872-464a-a470-e021cc7e80b6", "id": "55116a6e-c872-464a-a470-e021cc7e80b6",
"account": "1dc41566-262e-4a95-b5f8-b347b532acec", "account": "1dc41566-262e-4a95-b5f8-b347b532acec",
@ -3498,7 +3498,7 @@ function testInstance(uuid) {
"wins": 14, "wins": 14,
"losses": 2 "losses": 2
}, },
"cryps": [ "constructs": [
{ {
"id": "8a34f320-ddc0-4d4b-99da-479da18fdb3a", "id": "8a34f320-ddc0-4d4b-99da-479da18fdb3a",
"account": "43e54b00-627d-459c-9d89-931e5c163602", "account": "43e54b00-627d-459c-9d89-931e5c163602",
@ -3783,7 +3783,7 @@ function testInstance(uuid) {
"wins": 15, "wins": 15,
"losses": 1 "losses": 1
}, },
"cryps": [ "constructs": [
{ {
"id": "0f93d522-3dce-429d-b373-9d3c0f97c4c1", "id": "0f93d522-3dce-429d-b373-9d3c0f97c4c1",
"account": "06e8a7b5-ca97-45cb-a8db-9aa1bfec5d23", "account": "06e8a7b5-ca97-45cb-a8db-9aa1bfec5d23",
@ -4068,7 +4068,7 @@ function testInstance(uuid) {
"wins": 2, "wins": 2,
"losses": 14 "losses": 14
}, },
"cryps": [ "constructs": [
{ {
"id": "ad0ba069-c20a-403e-b90e-024af247e5d6", "id": "ad0ba069-c20a-403e-b90e-024af247e5d6",
"account": "a5867e13-b591-47c7-b9e8-3bd7fe56e17e", "account": "a5867e13-b591-47c7-b9e8-3bd7fe56e17e",
@ -4367,7 +4367,7 @@ function testInstance(uuid) {
"wins": 0, "wins": 0,
"losses": 16 "losses": 16
}, },
"cryps": [ "constructs": [
{ {
"id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd", "id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"account": uuid, "account": uuid,

View File

@ -57,10 +57,10 @@ function requestAvatar(name) {
} }
const animations = {}; const animations = {};
function animateCryp(id) { function animateConstruct(id) {
if (animations[id]) return false; if (animations[id]) return false;
animations[id] = true; animations[id] = true;
const duration = anime.random(2000, 20000); const duration = anime.random(2000, 8000);
const target = document.getElementById(id); const target = document.getElementById(id);
return anime({ return anime({
targets: target, targets: target,
@ -79,9 +79,9 @@ function clearAnimation(id) {
animations[id] = false; animations[id] = false;
} }
function crypAvatar(name, id) { function constructAvatar(name, id) {
useEffect(() => { useEffect(() => {
animateCryp(id); animateConstruct(id);
return () => clearAnimation(id); return () => clearAnimation(id);
}); });
@ -95,9 +95,9 @@ function crypAvatar(name, id) {
); );
} }
function instanceCryp(name, id) { function instanceConstruct(name, id) {
useEffect(() => { useEffect(() => {
animateCryp(id); animateConstruct(id);
return () => clearAnimation(id); return () => clearAnimation(id);
}); });
@ -286,52 +286,52 @@ const COLOUR_ICONS = {
green: { colour: 'green', caption: 'green', svg: shapes.square }, green: { colour: 'green', caption: 'green', svg: shapes.square },
}; };
function resoCrypHealth(resolution, currentGame) { function resoConstructHealth(resolution, currentGame) {
if (!resolution) return false; if (!resolution) return false;
const modifyHealth = cryp => { const modifyHealth = construct => {
if (cryp.id !== resolution.target.id) return false; // not target if (construct.id !== resolution.target.id) return false; // not target
const [type, event] = resolution.event; const [type, event] = resolution.event;
if (type === 'Damage') { if (type === 'Damage') {
const { amount, mitigation, colour } = event; const { amount, mitigation, colour } = event;
cryp.green_life.value -= amount; construct.green_life.value -= amount;
if (colour === 'Red') { if (colour === 'Red') {
cryp.red_life.value -= mitigation; construct.red_life.value -= mitigation;
} }
if (colour === 'Blue') { if (colour === 'Blue') {
cryp.blue_life.value -= mitigation; construct.blue_life.value -= mitigation;
} }
} }
if (type === 'Healing') { if (type === 'Healing') {
const { amount } = event; const { amount } = event;
cryp.green_life.value += amount; construct.green_life.value += amount;
} }
if (type === 'Recharge') { if (type === 'Recharge') {
const { red, blue } = event; const { red, blue } = event;
cryp.red_life.value += red; construct.red_life.value += red;
cryp.blue_life.value += blue; construct.blue_life.value += blue;
} }
return true; return true;
}; };
currentGame.players.forEach(player => player.cryps.forEach(modifyHealth)); currentGame.players.forEach(player => player.constructs.forEach(modifyHealth));
return true; return true;
} }
function eventClasses(resolution, cryp) { function eventClasses(resolution, construct) {
if (!resolution) return ''; if (!resolution) return '';
const startSkill = resolution.stage === 'START_SKILL'; const startSkill = resolution.stage === 'START_SKILL';
const endSkill = resolution.stage === 'END_SKILL'; const endSkill = resolution.stage === 'END_SKILL';
const postSkill = resolution.stage === 'POST_SKILL'; const postSkill = resolution.stage === 'POST_SKILL';
const source = cryp.id === resolution.source.id; const source = construct.id === resolution.source.id;
const target = cryp.id === resolution.target.id; const target = construct.id === resolution.target.id;
// not involved at all. blur them // not involved at all. blur them
if (!(source || target)) return 'unfocus'; if (!(source || target)) return 'unfocus';
// not the target. just ignore for now // not the target. just ignore for now
// if (cryp.id !== resolution.target.id) return ''; // if (construct.id !== resolution.target.id) return '';
const [type, event] = resolution.event; const [type, event] = resolution.event;
@ -357,7 +357,7 @@ function eventClasses(resolution, cryp) {
if (source && startSkill) return 'active-skill'; if (source && startSkill) return 'active-skill';
if (target && endSkill) return 'active-skill'; if (target && endSkill) return 'active-skill';
// Deal damage to cryp and return effect // Deal damage to construct and return effect
if (target && postSkill) { if (target && postSkill) {
if (colour === 'Red') { if (colour === 'Red') {
return 'red-damage'; return 'red-damage';
@ -457,13 +457,13 @@ function getCombatSequence(event) {
return ['START_SKILL', 'END_SKILL', 'POST_SKILL']; return ['START_SKILL', 'END_SKILL', 'POST_SKILL'];
} }
function getCombatText(cryp, resolution) { function getCombatText(construct, resolution) {
if (!resolution) return ['', '']; if (!resolution) return ['', ''];
const [type, event] = resolution.event; const [type, event] = resolution.event;
const source = cryp.id === resolution.source.id; const source = construct.id === resolution.source.id;
const target = cryp.id === resolution.target.id; const target = construct.id === resolution.target.id;
const startSkill = resolution.stage === 'START_SKILL'; const startSkill = resolution.stage === 'START_SKILL';
const endSkill = resolution.stage === 'END_SKILL'; const endSkill = resolution.stage === 'END_SKILL';
const postSkill = resolution.stage === 'POST_SKILL'; const postSkill = resolution.stage === 'POST_SKILL';
@ -567,18 +567,18 @@ function convertItem(v) {
} }
module.exports = { module.exports = {
animateCryp, animateConstruct,
stringSort, stringSort,
convertItem, convertItem,
numSort, numSort,
genAvatar, genAvatar,
crypAvatar, constructAvatar,
instanceCryp, instanceConstruct,
requestAvatar, requestAvatar,
eventClasses, eventClasses,
getCombatSequence, getCombatSequence,
getCombatText, getCombatText,
resoCrypHealth, resoConstructHealth,
NULL_UUID, NULL_UUID,
STATS, STATS,
SPECS, SPECS,

View File

@ -1,4 +1,4 @@
upstream cryps { upstream mnml {
server 127.0.0.1:40000; server 127.0.0.1:40000;
} }
@ -8,10 +8,14 @@ map $http_upgrade $connection_upgrade {
} }
server { server {
root /home/git/cryps/client/dist/; root /home/git/constructs/client/dist/;
index index.html; index index.html;
server_name cryps.gg; # managed by Certbot server_name mnml.gg; # managed by Certbot
if ($host = minimal.gg) {
return 301 https://mnml.gg$request_uri;
} # managed by Certbot
location / { location / {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
@ -19,13 +23,13 @@ server {
listen [::]:443 ssl ipv6only=on; # managed by Certbot listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cryps.gg/fullchain.pem; # managed by Certbot ssl_certificate /etc/letsenconstructt/live/mnml.gg/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cryps.gg/privkey.pem; # managed by Certbot ssl_certificate_key /etc/letsenconstructt/live/mnml.gg/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot include /etc/letsenconstructt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot ssl_dhparam /etc/letsenconstructt/ssl-dhparams.pem; # managed by Certbot
location /ws { location /ws {
proxy_pass http://cryps; proxy_pass http://mnml;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; proxy_set_header Connection $connection_upgrade;
@ -34,12 +38,16 @@ server {
} }
server { server {
if ($host = cryps.gg) { server_name mnml.gg;
return 301 https://$host$request_uri; return 301 https://$host$request_uri;
} # managed by Certbot }
listen 80 ; server {
listen [::]:80 ; server_name minimal.gg;
server_name cryps.gg; return 301 https://mnml.gg$request_uri;
return 404; # managed by Certbot }
server {
server_name constructs.gg;
return 301 https://mnml.gg$request_uri;
} }

View File

@ -2,10 +2,10 @@
# sudo apt-get install -y postgresql postgresql-contrib # sudo apt-get install -y postgresql postgresql-contrib
sudo service postgresql start sudo service postgresql start
sudo -u postgres dropdb cryps sudo -u postgres dropdb constructs
sudo -u postgres createdb cryps sudo -u postgres createdb constructs
sudo -u postgres createuser --encrypted cryps sudo -u postgres createuser --enconstructted constructs
sudo -u postgres psql -c "alter user cryps with encrypted password 'craftbeer';" sudo -u postgres psql -c "alter user constructs with enconstructted password 'craftbeer';"
# npm i # npm i
npm run migrate npm run migrate

View File

@ -3,8 +3,8 @@
const local = { const local = {
client: 'postgresql', client: 'postgresql',
connection: { connection: {
database: 'cryps', database: 'constructs',
user: 'cryps', user: 'constructs',
password: 'craftbeer' password: 'craftbeer'
}, },
pool: { pool: {

View File

@ -1,5 +1,5 @@
exports.up = async knex => { exports.up = async knex => {
return knex.schema.createTable('cryps', table => { return knex.schema.createTable('constructs', table => {
table.uuid('id').primary(); table.uuid('id').primary();
table.uuid('account').notNullable() table.uuid('account').notNullable()
table.foreign('account') table.foreign('account')

View File

@ -1,5 +1,5 @@
{ {
"name": "cryps-ops", "name": "constructs-ops",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>cryps.gg - mnml pvp atbs</title> <title>constructs.gg - mnml pvp atbs</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script> <link rel="stylesheet" href="./node_modules/izitoast/dist/css/iziToast.min.css"></script>

View File

@ -1,4 +1,4 @@
require('./cryps.css'); require('./constructs.css');
// kick it off // kick it off
require('./src/main'); require('./src/main');

View File

@ -1,5 +1,5 @@
{ {
"name": "cryps-client", "name": "constructs-client",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",

View File

@ -1,13 +1,13 @@
const toast = require('izitoast'); const toast = require('izitoast');
function registerEvents(registry, events, tutorial) { function registerEvents(registry, events, tutorial) {
function setCryps(cryps) { function setConstructs(constructs) {
registry.set('cryps', cryps); registry.set('constructs', constructs);
tutorial('homepage'); tutorial('homepage');
} }
function setCrypList(cryps) { function setConstructList(constructs) {
registry.set('crypList', cryps); registry.set('constructList', constructs);
} }
@ -65,30 +65,30 @@ function registerEvents(registry, events, tutorial) {
registry.set('gameList', gameList); registry.set('gameList', gameList);
} }
function setCrypStatusUpdate(id, skill, target) { function setConstructStatusUpdate(id, skill, target) {
registry.set('crypStatusUpdate', { id, skill, target }); registry.set('constructStatusUpdate', { id, skill, target });
} }
events.on('SET_PLAYER', setPlayer); events.on('SET_PLAYER', setPlayer);
events.on('SEND_SKILL', function skillActive(gameId, crypId, targetCrypId, skill) { events.on('SEND_SKILL', function skillActive(gameId, constructId, targetConstructId, skill) {
const ws = registry.get('ws'); const ws = registry.get('ws');
ws.sendGameSkill(gameId, crypId, targetCrypId, skill); ws.sendGameSkill(gameId, constructId, targetConstructId, skill);
setCrypStatusUpdate(crypId, skill, targetCrypId); setConstructStatusUpdate(constructId, skill, targetConstructId);
}); });
events.on('CRYP_ACTIVE', function crypActiveCb(cryp) { events.on('CONSTRUCT_ACTIVE', function constructActiveCb(construct) {
const cryps = registry.get('cryps'); const constructs = registry.get('constructs');
for (let i = 0; i < cryps.length; i += 1) { for (let i = 0; i < constructs.length; i += 1) {
if (cryps[i].id === cryp.id) cryps[i].active = !cryps[i].active; if (constructs[i].id === construct.id) constructs[i].active = !constructs[i].active;
} }
return setCryps(cryps); return setConstructs(constructs);
}); });
const errMessages = { const errMessages = {
select_cryps: 'Select your cryps before battle using the numbered buttons next to the cryp avatar', select_constructs: 'Select your constructs before battle using the numbered buttons next to the construct avatar',
complete_nodes: 'You need to complete the previously connected nodes first', complete_nodes: 'You need to complete the previously connected nodes first',
max_skills: 'Your cryp can only learn a maximum of 4 skills', max_skills: 'Your construct can only learn a maximum of 4 skills',
}; };
@ -165,7 +165,7 @@ function registerEvents(registry, events, tutorial) {
}); });
} }
events.on('CRYP_SPAWN', function spawnPrompt() { events.on('CONSTRUCT_SPAWN', function spawnPrompt() {
const NAME_INPUT = '<input className="input" type="email" placeholder="name" />'; const NAME_INPUT = '<input className="input" type="email" placeholder="name" />';
const SPAWN_BUTTON = '<button type="submit">SPAWN</button>'; const SPAWN_BUTTON = '<button type="submit">SPAWN</button>';
@ -173,7 +173,7 @@ function registerEvents(registry, events, tutorial) {
function submitSpawn(instance, thisToast, button, e, inputs) { function submitSpawn(instance, thisToast, button, e, inputs) {
const NAME = inputs[0].value; const NAME = inputs[0].value;
ws.sendCrypSpawn(NAME); ws.sendConstructSpawn(NAME);
instance.hide({ transitionOut: 'fadeOut' }, thisToast, 'button'); instance.hide({ transitionOut: 'fadeOut' }, thisToast, 'button');
} }
@ -184,7 +184,7 @@ function registerEvents(registry, events, tutorial) {
// overlay: true, // overlay: true,
drag: false, drag: false,
close: true, close: true,
title: 'SPAWN CRYP', title: 'SPAWN CONSTRUCT',
position: 'center', position: 'center',
inputs: [ inputs: [
[NAME_INPUT, 'change', null, true], // true to focus [NAME_INPUT, 'change', null, true], // true to focus
@ -202,8 +202,8 @@ function registerEvents(registry, events, tutorial) {
loginPrompt, loginPrompt,
setAccount, setAccount,
setActiveSkill, setActiveSkill,
setCryps, setConstructs,
setCrypList, setConstructList,
setGame, setGame,
setMenu, setMenu,
setPlayer, setPlayer,

View File

@ -1,11 +1,11 @@
const renderCryps = require('./scenes/cryps'); const renderConstructs = require('./scenes/constructs');
const createSocket = require('./socket'); const createSocket = require('./socket');
const registerEvents = require('./events'); const registerEvents = require('./events');
const createTutorial = require('./tutorial'); const createTutorial = require('./tutorial');
document.fonts.load('10pt "Jura"').then(() => { document.fonts.load('10pt "Jura"').then(() => {
const game = renderCryps(); const game = renderConstructs();
const tutorial = createTutorial(); const tutorial = createTutorial();
const events = registerEvents(game.registry, game.events, tutorial); const events = registerEvents(game.registry, game.events, tutorial);
const ws = createSocket(events); const ws = createSocket(events);

View File

@ -40,7 +40,7 @@ class CombatSkills extends Phaser.GameObjects.Group {
} }
genericHeal(sourceAlly, castLocation) { genericHeal(sourceAlly, castLocation) {
// const { sourceX, sourceY } = getCrypPosition(sourcePos, 0); // const { sourceX, sourceY } = getConstructPosition(sourcePos, 0);
const lifespan = DELAYS.ANIMATION_DURATION; const lifespan = DELAYS.ANIMATION_DURATION;
const colour = randomColour(); const colour = randomColour();
const particles = this.scene.add.particles(colour); const particles = this.scene.add.particles(colour);

View File

@ -4,27 +4,27 @@ const StatBar = require('./elements/combat.statbar');
const { DELAYS, TEXT, POSITIONS: { COMBAT } } = require('./constants'); const { DELAYS, TEXT, POSITIONS: { COMBAT } } = require('./constants');
const CRYP_MARGIN = COMBAT.crypMargin(); const CONSTRUCT_MARGIN = COMBAT.constructMargin();
const TEXT_MARGIN = COMBAT.textMargin(); const TEXT_MARGIN = COMBAT.textMargin();
const crypAvatarText = (team, iter) => { const constructAvatarText = (team, iter) => {
const nameX = COMBAT.width() * team; const nameX = COMBAT.width() * team;
const nameY = COMBAT.y() + CRYP_MARGIN * iter + COMBAT.height() * 0.07; const nameY = COMBAT.y() + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07;
const statusX = COMBAT.width() * team; const statusX = COMBAT.width() * team;
const statusY = COMBAT.y() + TEXT_MARGIN * 6 + CRYP_MARGIN * iter + COMBAT.height() * 0.07; const statusY = COMBAT.y() + TEXT_MARGIN * 6 + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07;
return { statusX, statusY, nameX, nameY }; return { statusX, statusY, nameX, nameY };
}; };
const crypEffects = (team, iter) => { const constructEffects = (team, iter) => {
const crypEffectsX = team ? COMBAT.width() - COMBAT.width() / 6.5 : COMBAT.width() / 6.5; const constructEffectsX = team ? COMBAT.width() - COMBAT.width() / 6.5 : COMBAT.width() / 6.5;
const crypEffectsY = TEXT_MARGIN * 2 + CRYP_MARGIN * iter; const constructEffectsY = TEXT_MARGIN * 2 + CONSTRUCT_MARGIN * iter;
return { crypEffectsX, crypEffectsY }; return { constructEffectsX, constructEffectsY };
}; };
const crypPosition = (team, iter) => { const constructPosition = (team, iter) => {
const crypAvatarX = team ? COMBAT.width() - COMBAT.width() / 6 : COMBAT.width() / 6; const constructAvatarX = team ? COMBAT.width() - COMBAT.width() / 6 : COMBAT.width() / 6;
const crypAvatarY = TEXT_MARGIN * 5 + CRYP_MARGIN * iter; const constructAvatarY = TEXT_MARGIN * 5 + CONSTRUCT_MARGIN * iter;
return { crypAvatarX, crypAvatarY }; return { constructAvatarX, constructAvatarY };
}; };
@ -32,8 +32,8 @@ class Effects extends Phaser.GameObjects.Group {
constructor(scene, team, iter) { constructor(scene, team, iter) {
super(scene); super(scene);
this.scene = scene; this.scene = scene;
const { crypEffectsX, crypEffectsY } = crypEffects(team, iter); const { constructEffectsX, constructEffectsY } = constructEffects(team, iter);
this.x = crypEffectsX; this.y = crypEffectsY; this.x = constructEffectsX; this.y = constructEffectsY;
this.effectCount = 0; this.effectCount = 0;
} }
@ -62,28 +62,28 @@ class Effects extends Phaser.GameObjects.Group {
} }
} }
class CrypImage extends Phaser.GameObjects.Image { class ConstructImage extends Phaser.GameObjects.Image {
constructor(scene, team, iter, cryp) { constructor(scene, team, iter, construct) {
// Get coords // Get coords
const { crypAvatarX, crypAvatarY } = crypPosition(team, iter); const { constructAvatarX, constructAvatarY } = constructPosition(team, iter);
const { statusX, statusY, nameX, nameY } = crypAvatarText(team, iter); const { statusX, statusY, nameX, nameY } = constructAvatarText(team, iter);
// Cryp display // Construct display
// const avatar = team ? 'magmar' : 'alk'; // const avatar = team ? 'magmar' : 'alk';
super(scene, crypAvatarX, crypAvatarY, 'aztec', genAvatar(cryp.name)); super(scene, constructAvatarX, constructAvatarY, 'aztec', genAvatar(construct.name));
this.setScale(0.5); this.setScale(0.5);
if (!team) this.flipX = true; if (!team) this.flipX = true;
// Save position and cryp details // Save position and construct details
this.scene = scene; this.scene = scene;
this.iter = iter; this.iter = iter;
this.team = team; this.team = team;
this.cryp = cryp; this.construct = construct;
this.state = 'deselect'; this.state = 'deselect';
// Add cryp name // Add construct name
scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0); scene.add.text(nameX, nameY, construct.name, TEXT.NORMAL).setOrigin(team, 0);
// Add cryp stat bars // Add construct stat bars
this.health = scene.add.existing(new StatBar(scene, this, 'HP')); this.health = scene.add.existing(new StatBar(scene, this, 'HP'));
this.red_shield = scene.add.existing(new StatBar(scene, this, 'Red Shield')); this.red_shield = scene.add.existing(new StatBar(scene, this, 'Red Shield'));
this.blue_shield = scene.add.existing(new StatBar(scene, this, 'Blue Shield')); this.blue_shield = scene.add.existing(new StatBar(scene, this, 'Blue Shield'));
@ -141,18 +141,18 @@ class CrypImage extends Phaser.GameObjects.Image {
} }
} }
class CombatCryps extends Phaser.Scene { class CombatConstructs extends Phaser.Scene {
constructor() { constructor() {
super({ key: 'CombatCryps' }); super({ key: 'CombatConstructs' });
} }
create(game) { create(game) {
this.cryps = this.add.group(); this.constructs = this.add.group();
this.phase = game.phase; this.phase = game.phase;
this.account = this.registry.get('account'); this.account = this.registry.get('account');
this.drawCryps(game); this.drawConstructs(game);
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.set('crypStatusUpdate', false); this.registry.set('constructStatusUpdate', false);
this.teams = game.teams.length; this.teams = game.teams.length;
} }
@ -168,65 +168,65 @@ class CombatCryps extends Phaser.Scene {
const shouldUpdate = data !== this.phase; const shouldUpdate = data !== this.phase;
this.phase = data; this.phase = data;
if (shouldUpdate) { if (shouldUpdate) {
this.cryps.children.entries.forEach(c => c.clearStatus()); this.constructs.children.entries.forEach(c => c.clearStatus());
this.drawCryps(this.game); this.drawConstructs(this.game);
} }
} }
if (key === 'crypStatusUpdate' && data) { if (key === 'constructStatusUpdate' && data) {
this.updateCrypStatus(data); this.updateConstructStatus(data);
} }
return true; return true;
} }
drawCryps(game) { drawConstructs(game) {
const renderCryp = (cryp, iter, team) => { const renderConstruct = (construct, iter, team) => {
// Add Image Avatar Class // Add Image Avatar Class
const crypObj = new CrypImage(this, team, iter, cryp); const constructObj = new ConstructImage(this, team, iter, construct);
this.add.existing(crypObj); this.add.existing(constructObj);
this.cryps.add(crypObj); this.constructs.add(constructObj);
return crypObj; return constructObj;
}; };
const renderTeam = (cryp, iter, team) => { const renderTeam = (construct, iter, team) => {
const crypObj = this.cryps.children.entries const constructObj = this.constructs.children.entries
.find(c => c.cryp.id === cryp.id) .find(c => c.construct.id === construct.id)
|| renderCryp(cryp, iter, team); || renderConstruct(construct, iter, team);
crypObj.health.val = cryp.hp.value; constructObj.health.val = construct.hp.value;
crypObj.red_shield.val = cryp.red_shield.value; constructObj.red_shield.val = construct.red_shield.value;
crypObj.blue_shield.val = cryp.red_shield.value; constructObj.blue_shield.val = construct.red_shield.value;
crypObj.health.drawStatBar(); constructObj.health.drawStatBar();
crypObj.red_shield.drawStatBar(); constructObj.red_shield.drawStatBar();
crypObj.blue_shield.drawStatBar(); constructObj.blue_shield.drawStatBar();
crypObj.effects.update(cryp.effects); constructObj.effects.update(construct.effects);
}; };
const allyTeam = game.teams.find(t => t.id === this.account.id); const allyTeam = game.teams.find(t => t.id === this.account.id);
// in future there will be more than one // in future there will be more than one
const [enemyTeam] = game.teams.filter(t => t.id !== this.account.id); const [enemyTeam] = game.teams.filter(t => t.id !== this.account.id);
allyTeam.cryps.forEach((cryp, i) => renderTeam(cryp, i, 0)); allyTeam.constructs.forEach((construct, i) => renderTeam(construct, i, 0));
if (!enemyTeam) return false; if (!enemyTeam) return false;
enemyTeam.cryps.forEach((cryp, i) => renderTeam(cryp, i, 1)); enemyTeam.constructs.forEach((construct, i) => renderTeam(construct, i, 1));
return true; return true;
} }
selectCryp(crypId) { selectConstruct(constructId) {
this.cryps.children.entries.forEach(c => c.deselect()); this.constructs.children.entries.forEach(c => c.deselect());
if (crypId) this.cryps.children.entries.find(c => c.cryp.id === crypId).select(); if (constructId) this.constructs.children.entries.find(c => c.construct.id === constructId).select();
} }
updateCrypStatus(status) { updateConstructStatus(status) {
const sourceCryp = this.cryps.children.entries const sourceConstruct = this.constructs.children.entries
.find(c => c.cryp.id === status.id); .find(c => c.construct.id === status.id);
const targetCryp = this.cryps.children.entries const targetConstruct = this.constructs.children.entries
.find(c => c.cryp.id === status.target); .find(c => c.construct.id === status.target);
if (this.phase === 'Skill') { if (this.phase === 'Skill') {
sourceCryp.statusText.text = `${status.skill} on ${targetCryp.cryp.name}`; sourceConstruct.statusText.text = `${status.skill} on ${targetConstruct.construct.name}`;
} }
} }
@ -236,4 +236,4 @@ class CombatCryps extends Phaser.Scene {
} }
} }
module.exports = CombatCryps; module.exports = CombatConstructs;

View File

@ -1,14 +1,14 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const { POSITIONS: { COMBAT } } = require('./constants'); const { POSITIONS: { COMBAT } } = require('./constants');
const CRYP_MARGIN = COMBAT.crypMargin(); const CONSTRUCT_MARGIN = COMBAT.constructMargin();
const BOX_HEIGHT = CRYP_MARGIN * 0.8; const BOX_HEIGHT = CONSTRUCT_MARGIN * 0.8;
const BOX_WIDTH = COMBAT.width() * 0.2; const BOX_WIDTH = COMBAT.width() * 0.2;
class CrypHitBox extends Phaser.GameObjects.Rectangle { class ConstructHitBox extends Phaser.GameObjects.Rectangle {
constructor(scene, iter, team, cback) { constructor(scene, iter, team, cback) {
const y = COMBAT.y() + COMBAT.height() * 0.05 + CRYP_MARGIN * iter; const y = COMBAT.y() + COMBAT.height() * 0.05 + CONSTRUCT_MARGIN * iter;
super(scene, (COMBAT.width() - BOX_WIDTH) * team, y, BOX_WIDTH, BOX_HEIGHT, 0x222222); super(scene, (COMBAT.width() - BOX_WIDTH) * team, y, BOX_WIDTH, BOX_HEIGHT, 0x222222);
this.setOrigin(0); this.setOrigin(0);
this.clickHandler = () => cback(); this.clickHandler = () => cback();
@ -59,22 +59,22 @@ class CombatHitBox extends Phaser.Scene {
skillHitBox(game) { skillHitBox(game) {
const account = this.registry.get('account'); const account = this.registry.get('account');
const group = this.scene.get('CombatCryps').cryps; const group = this.scene.get('CombatConstructs').constructs;
const skillScene = this.scene.get('CombatSkills'); const skillScene = this.scene.get('CombatSkills');
game.teams.forEach((t) => { game.teams.forEach((t) => {
t.cryps.forEach((c) => { t.constructs.forEach((c) => {
const cback = () => { const cback = () => {
const { activeSkill } = skillScene; const { activeSkill } = skillScene;
if (activeSkill) { if (activeSkill) {
this.scene.get('CombatSkills').clearCrypActive(activeSkill.cryp.id); this.scene.get('CombatSkills').clearConstructActive(activeSkill.construct.id);
activeSkill.activate(); activeSkill.activate();
skillScene.activeSkill = null; skillScene.activeSkill = null;
this.game.events.emit('SEND_SKILL', game.id, activeSkill.cryp.id, c.id, activeSkill.skill.skill); this.game.events.emit('SEND_SKILL', game.id, activeSkill.construct.id, c.id, activeSkill.skill.skill);
} }
}; };
const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id); const constructSpawn = group.children.entries.find(s => s.construct.id === c.id);
const team = c.account === account.id ? 0 : 1; const team = c.account === account.id ? 0 : 1;
if (crypSpawn) this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback)); if (constructSpawn) this.add.existing(new ConstructHitBox(this, constructSpawn.iter, team, cback));
}); });
}); });
this.scene.moveBelow('Combat'); this.scene.moveBelow('Combat');

View File

@ -3,7 +3,7 @@ const { throttle } = require('lodash');
const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); const { TEXT, POSITIONS: { COMBAT } } = require('./constants');
const CombatLog = require('./combat.log'); const CombatLog = require('./combat.log');
const CombatCryps = require('./combat.cryps'); const CombatConstructs = require('./combat.constructs');
const CombatSkills = require('./combat.skills'); const CombatSkills = require('./combat.skills');
const CombatHitBox = require('./combat.hitbox'); const CombatHitBox = require('./combat.hitbox');
@ -47,7 +47,7 @@ class Combat extends Phaser.Scene {
} }
startGame(game) { startGame(game) {
this.scene.manager.add('CombatCryps', CombatCryps, true, game); this.scene.manager.add('CombatConstructs', CombatConstructs, true, game);
this.scene.manager.add('CombatLog', CombatLog, true, game); this.scene.manager.add('CombatLog', CombatLog, true, game);
this.renderedResolves = game.resolved.length; // In case you rejoin mid way this.renderedResolves = game.resolved.length; // In case you rejoin mid way
this.scene.manager.add('CombatSkills', CombatSkills, true, game.phase); this.scene.manager.add('CombatSkills', CombatSkills, true, game.phase);
@ -79,7 +79,7 @@ class Combat extends Phaser.Scene {
} }
checkAnimation(game) { checkAnimation(game) {
// Check cryps are loaded and whether game is animating // Check constructs are loaded and whether game is animating
const cantAnimate = this.registry.get('gamePhase') === 'animating'; const cantAnimate = this.registry.get('gamePhase') === 'animating';
if (cantAnimate) return false; if (cantAnimate) return false;
if (game.resolved.length !== this.renderedResolves) { if (game.resolved.length !== this.renderedResolves) {
@ -125,7 +125,7 @@ class Combat extends Phaser.Scene {
this.registry.set('menu', true); this.registry.set('menu', true);
this.registry.set('game', null); this.registry.set('game', null);
const ACTIVE_SCENES = ['CombatLog', 'CombatCryps', 'CombatSkills', 'CombatHitBox']; const ACTIVE_SCENES = ['CombatLog', 'CombatConstructs', 'CombatSkills', 'CombatHitBox'];
ACTIVE_SCENES.forEach((sKey) => { ACTIVE_SCENES.forEach((sKey) => {
if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp(); if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp();
}); });

View File

@ -6,23 +6,23 @@ const {
POSITIONS: { COMBAT }, POSITIONS: { COMBAT },
} = require('./constants'); } = require('./constants');
function findResolutionCryps(scene, group, resolution, game) { function findResolutionConstructs(scene, group, resolution, game) {
const sourceSpawn = group.children.entries.find(c => c.cryp.id === resolution.source.id); const sourceSpawn = group.children.entries.find(c => c.construct.id === resolution.source.id);
/* const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id)) /* const sourceConstruct = game.teams.find(t => t.constructs.find(c => c.id === resolution.source_construct_id))
.cryps.find(c => c.id === resolution.source_cryp_id); .constructs.find(c => c.id === resolution.source_construct_id);
const targetCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.target_cryp_id)) const targetConstruct = game.teams.find(t => t.constructs.find(c => c.id === resolution.target_construct_id))
.cryps.find(c => c.id === resolution.target_cryp_id); .constructs.find(c => c.id === resolution.target_construct_id);
*/ */
const targetSpawn = group.children.entries.find(c => c.cryp.id === resolution.target.id); const targetSpawn = group.children.entries.find(c => c.construct.id === resolution.target.id);
return { sourceSpawn, targetSpawn }; return { sourceSpawn, targetSpawn };
} }
function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) { function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) {
const tweenParams = (targets, centreSpot) => { const tweenParams = (targets, centreSpot) => {
const enemy = targets.cryp.account !== account.id; const enemy = targets.construct.account !== account.id;
let x = centreSpot ? COMBAT.width() * 0.3 : targets.x; let x = centreSpot ? COMBAT.width() * 0.3 : targets.x;
x = (enemy && centreSpot) ? x + COMBAT.width() * 0.4 : x; x = (enemy && centreSpot) ? x + COMBAT.width() * 0.4 : x;
const y = centreSpot ? COMBAT.height() * 13.25 / 35 : targets.y; const y = centreSpot ? COMBAT.height() * 13.25 / 35 : targets.y;
@ -36,7 +36,7 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) {
let moveSourceOrig = false; let moveSourceOrig = false;
const targetOnlySkill = ['DecayTick']; const targetOnlySkill = ['DecayTick'];
if (!(targetOnlySkill.includes(skill))) { if (!(targetOnlySkill.includes(skill))) {
if (sourceSpawn.cryp.account !== targetSpawn.cryp.account) { if (sourceSpawn.construct.account !== targetSpawn.construct.account) {
moveSourceBattle = tweenParams(sourceSpawn, true); moveSourceBattle = tweenParams(sourceSpawn, true);
moveSourceOrig = tweenParams(sourceSpawn, false); moveSourceOrig = tweenParams(sourceSpawn, false);
} }
@ -57,12 +57,12 @@ function animatePhase(scene, game, resolution, cb) {
|| resolution.event[0] === 'TargetKo' || resolution.event[0] === 'TargetKo'
|| resolution.event === 'Ko') return cb(); || resolution.event === 'Ko') return cb();
const group = scene.scene.get('CombatCryps').cryps; const group = scene.scene.get('CombatConstructs').constructs;
const animations = new CombatAnimations(scene); const animations = new CombatAnimations(scene);
const account = scene.registry.get('account'); const account = scene.registry.get('account');
// Find cryps, targets // Find constructs, targets
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game); const { sourceSpawn, targetSpawn } = findResolutionConstructs(scene, group, resolution, game);
const { const {
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig, moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
} = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill); } = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill);
@ -74,16 +74,16 @@ function animatePhase(scene, game, resolution, cb) {
}; };
const castLocation = castParams(); const castLocation = castParams();
// Move cryps into position // Move constructs into position
if (moveSourceBattle) scene.tweens.add(moveSourceBattle); if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
scene.tweens.add(moveTargetBattle); scene.tweens.add(moveTargetBattle);
return scene.time.delayedCall(MOVE_CREEP, () => { return scene.time.delayedCall(MOVE_CREEP, () => {
const sourceAlly = sourceSpawn.cryp.account === account.id; const sourceAlly = sourceSpawn.construct.account === account.id;
const targetAlly = targetSpawn.cryp.account === account.id; const targetAlly = targetSpawn.construct.account === account.id;
// animate animation // animate animation
animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation); animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation);
// Target cryp takes damage // Target construct takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => { scene.time.delayedCall(ANIMATION_DURATION, () => {
console.log(resolution); console.log(resolution);
if (resolution.event[0] === 'Damage') { if (resolution.event[0] === 'Damage') {

View File

@ -2,18 +2,18 @@ const Phaser = require('phaser');
const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); const { TEXT, POSITIONS: { COMBAT } } = require('./constants');
const CRYP_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE']; const CONSTRUCT_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE'];
const SKILL_KEY_MAP = ['keydown_Q', 'keydown_W', 'keydown_E', 'keydown_R']; const SKILL_KEY_MAP = ['keydown_Q', 'keydown_W', 'keydown_E', 'keydown_R'];
const TARGET_KEY_MAP = ['keydown_SEVEN', 'keydown_EIGHT', 'keydown_NINE', 'keydown_ZERO']; const TARGET_KEY_MAP = ['keydown_SEVEN', 'keydown_EIGHT', 'keydown_NINE', 'keydown_ZERO'];
const CRYP_MARGIN = COMBAT.crypMargin(); const CONSTRUCT_MARGIN = COMBAT.constructMargin();
const TEXT_MARGIN = COMBAT.textMargin(); const TEXT_MARGIN = COMBAT.textMargin();
const SKILL_WIDTH = COMBAT.width() / 10; const SKILL_WIDTH = COMBAT.width() / 10;
const SKILL_HEIGHT = COMBAT.height() / 30; const SKILL_HEIGHT = COMBAT.height() / 30;
const skillPosition = (crypIter, skillIter) => { const skillPosition = (constructIter, skillIter) => {
const skillTextX = COMBAT.width() / 3.8; const skillTextX = COMBAT.width() / 3.8;
const skillTextY = (TEXT_MARGIN * skillIter) * 1.5 + CRYP_MARGIN * crypIter + COMBAT.y() + COMBAT.height() * 0.07; const skillTextY = (TEXT_MARGIN * skillIter) * 1.5 + CONSTRUCT_MARGIN * constructIter + COMBAT.y() + COMBAT.height() * 0.07;
return [skillTextX, skillTextY]; return [skillTextX, skillTextY];
}; };
@ -28,9 +28,9 @@ const skillCheckHitBox = (scenePlugin, pointer) => {
return false; return false;
}; };
class CrypSkill extends Phaser.GameObjects.Container { class ConstructSkill extends Phaser.GameObjects.Container {
constructor(scene, x, y, skill, cryp) { constructor(scene, x, y, skill, construct) {
// Avatar will be a property of cryp // Avatar will be a property of construct
super(scene, x, y); super(scene, x, y);
const CD_TEXT = skill.cd ? `(${skill.cd}T)` : ''; const CD_TEXT = skill.cd ? `(${skill.cd}T)` : '';
const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`; const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`;
@ -42,7 +42,7 @@ class CrypSkill extends Phaser.GameObjects.Container {
this.add(this.skillText); this.add(this.skillText);
this.state = 'deselect'; this.state = 'deselect';
this.cryp = cryp; this.construct = construct;
this.skill = skill; this.skill = skill;
this.scene = scene; this.scene = scene;
@ -117,7 +117,7 @@ class CombatSkills extends Phaser.Scene {
if (key === 'gamePhase' && data) { if (key === 'gamePhase' && data) {
const shouldUpdate = data !== this.phase; const shouldUpdate = data !== this.phase;
if (shouldUpdate) { if (shouldUpdate) {
this.scene.get('CombatCryps').selectCryp(null); this.scene.get('CombatConstructs').selectConstruct(null);
return this.scene.restart(data); return this.scene.restart(data);
} }
return false; return false;
@ -135,9 +135,9 @@ class CombatSkills extends Phaser.Scene {
const { keyboard } = this.input; const { keyboard } = this.input;
const { events } = this.game; const { events } = this.game;
const addSkill = (i, j, skill, cryp) => { const addSkill = (i, j, skill, construct) => {
const skillTextPos = skillPosition(i, j); const skillTextPos = skillPosition(i, j);
const skillObj = new CrypSkill(this, skillTextPos[0], skillTextPos[1], skill, cryp); const skillObj = new ConstructSkill(this, skillTextPos[0], skillTextPos[1], skill, construct);
if (skill.cd) { if (skill.cd) {
skillObj.skillBox.setFillStyle(0x9d9ea0); skillObj.skillBox.setFillStyle(0x9d9ea0);
} else { } else {
@ -150,22 +150,22 @@ class CombatSkills extends Phaser.Scene {
const team = game.teams.find(t => t.id === account.id); const team = game.teams.find(t => t.id === account.id);
const enemyTeam = game.teams.find(t => t.id !== account.id); const enemyTeam = game.teams.find(t => t.id !== account.id);
team.cryps.forEach((cryp) => { team.constructs.forEach((construct) => {
// return early if KOd // return early if KOd
if (cryp.hp.value === 0) return true; if (construct.hp.value === 0) return true;
// find the cryp position // find the construct position
const { iter } = this.scene.get('CombatCryps').cryps.children.entries.find(c => c.cryp.id === cryp.id); const { iter } = this.scene.get('CombatConstructs').constructs.children.entries.find(c => c.construct.id === construct.id);
// draw the skills // draw the skills
const skillButtons = cryp.skills.map((skill, j) => addSkill(iter, j, skill, cryp)); const skillButtons = construct.skills.map((skill, j) => addSkill(iter, j, skill, construct));
const bindCrypKeys = () => this.mapSkillKeys(skillButtons, game.id, cryp.id, team.id, enemyTeam.id, iter); const bindConstructKeys = () => this.mapSkillKeys(skillButtons, game.id, construct.id, team.id, enemyTeam.id, iter);
// reset everything // reset everything
keyboard.on('keydown_ESC', bindCrypKeys, this); keyboard.on('keydown_ESC', bindConstructKeys, this);
events.on('SEND_SKILL', bindCrypKeys, this); events.on('SEND_SKILL', bindConstructKeys, this);
bindCrypKeys(); bindConstructKeys();
return true; return true;
}); });
@ -174,16 +174,16 @@ class CombatSkills extends Phaser.Scene {
} }
// FIXME // FIXME
// needs to send crypId not team // needs to send constructId not team
mapSkillKeys(skillButtons, gameId, crypId, alliesId, enemyId, i) { mapSkillKeys(skillButtons, gameId, constructId, alliesId, enemyId, i) {
const { keyboard } = this.input; const { keyboard } = this.input;
keyboard.removeListener(CRYP_KEY_MAP[i]); keyboard.removeListener(CONSTRUCT_KEY_MAP[i]);
keyboard.on(CRYP_KEY_MAP[i], () => { keyboard.on(CONSTRUCT_KEY_MAP[i], () => {
SKILL_KEY_MAP.forEach(k => keyboard.removeListener(k)); SKILL_KEY_MAP.forEach(k => keyboard.removeListener(k));
this.scene.get('CombatCryps').selectCryp(crypId); this.scene.get('CombatConstructs').selectConstruct(constructId);
skillButtons.forEach((button, j) => { skillButtons.forEach((button, j) => {
keyboard.on(SKILL_KEY_MAP[j], () => { keyboard.on(SKILL_KEY_MAP[j], () => {
@ -191,21 +191,21 @@ class CombatSkills extends Phaser.Scene {
button.select(); button.select();
// clear existing keys // clear existing keys
CRYP_KEY_MAP.forEach(k => keyboard.removeListener(k)); CONSTRUCT_KEY_MAP.forEach(k => keyboard.removeListener(k));
TARGET_KEY_MAP.forEach(k => keyboard.removeListener(k)); TARGET_KEY_MAP.forEach(k => keyboard.removeListener(k));
CRYP_KEY_MAP.forEach(k => keyboard.on(k, () => { CONSTRUCT_KEY_MAP.forEach(k => keyboard.on(k, () => {
this.clearCrypActive(crypId); this.clearConstructActive(constructId);
button.activate(); button.activate();
this.activeSkill = null; this.activeSkill = null;
this.game.events.emit('SEND_SKILL', gameId, crypId, alliesId, button.skill.skill); this.game.events.emit('SEND_SKILL', gameId, constructId, alliesId, button.skill.skill);
})); }));
TARGET_KEY_MAP.forEach(k => keyboard.on(k, () => { TARGET_KEY_MAP.forEach(k => keyboard.on(k, () => {
this.clearCrypActive(crypId); this.clearConstructActive(constructId);
button.activate(); button.activate();
this.activeSkill = null; this.activeSkill = null;
this.game.events.emit('SEND_SKILL', gameId, crypId, enemyId, button.skill.skill); this.game.events.emit('SEND_SKILL', gameId, constructId, enemyId, button.skill.skill);
})); }));
}, this); }, this);
}); });
@ -214,15 +214,15 @@ class CombatSkills extends Phaser.Scene {
return true; return true;
} }
clearCrypActive(crypId) { clearConstructActive(constructId) {
this.scene.scene.children.list.forEach((s) => { this.scene.scene.children.list.forEach((s) => {
if (s.cryp.id === crypId && s.state === 'activate') s.deselect(); if (s.construct.id === constructId && s.state === 'activate') s.deselect();
}); });
} }
clearKeys() { clearKeys() {
TARGET_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); TARGET_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey));
CRYP_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); CONSTRUCT_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey));
SKILL_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); SKILL_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey));
} }

View File

@ -7,10 +7,10 @@ const CANVAS_HEIGHT = () => Math.floor(window.innerHeight);
const headerWidth = () => CANVAS_WIDTH(); const headerWidth = () => CANVAS_WIDTH();
const headerHeight = () => Math.floor(CANVAS_HEIGHT() * 0.05); const headerHeight = () => Math.floor(CANVAS_HEIGHT() * 0.05);
const menuCrypListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3); const menuConstructListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3);
const menuCrypListHeight = () => Math.floor(CANVAS_HEIGHT() - headerHeight()); const menuConstructListHeight = () => Math.floor(CANVAS_HEIGHT() - headerHeight());
const menuCrypListX = () => Math.floor(CANVAS_WIDTH() * 0.3); const menuConstructListX = () => Math.floor(CANVAS_WIDTH() * 0.3);
const menuCrypListY = () => headerHeight(); const menuConstructListY = () => headerHeight();
const itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5); const itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5);
const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.95); const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.95);
@ -38,13 +38,13 @@ const combatWidth = () => CANVAS_WIDTH();
const combatHeight = () => CANVAS_HEIGHT() - headerHeight(); const combatHeight = () => CANVAS_HEIGHT() - headerHeight();
const combatY = () => headerHeight(); const combatY = () => headerHeight();
const combatX = () => 0; const combatX = () => 0;
const combatCrypMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 4.5); const combatConstructMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 4.5);
const combatTextMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 35); const combatTextMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 35);
const statsWidth = () => Math.floor(CANVAS_WIDTH() - menuCrypListWidth()); const statsWidth = () => Math.floor(CANVAS_WIDTH() - menuConstructListWidth());
const statsHeight = () => CANVAS_HEIGHT() - headerHeight(); const statsHeight = () => CANVAS_HEIGHT() - headerHeight();
const statsY = () => headerHeight(); const statsY = () => headerHeight();
const statsX = () => menuCrypListWidth(); const statsX = () => menuConstructListWidth();
const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4);
const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2); const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2);
const statsTextMargin = () => 24; const statsTextMargin = () => 24;
@ -70,11 +70,11 @@ module.exports = {
height: headerHeight, height: headerHeight,
}, },
CRYP_LIST: { CONSTRUCT_LIST: {
x: menuCrypListX, x: menuConstructListX,
y: menuCrypListY, y: menuConstructListY,
width: menuCrypListWidth, width: menuConstructListWidth,
height: menuCrypListHeight, height: menuConstructListHeight,
}, },
MENU_MAIN: { MENU_MAIN: {
@ -127,7 +127,7 @@ module.exports = {
y: combatY, y: combatY,
width: combatWidth, width: combatWidth,
height: combatHeight, height: combatHeight,
crypMargin: combatCrypMargin, constructMargin: combatConstructMargin,
textMargin: combatTextMargin, textMargin: combatTextMargin,
@ -172,7 +172,7 @@ module.exports = {
ITEMS: { ITEMS: {
SKILLS: { SKILLS: {
Amplify: { Amplify: {
description: 'increase the magic damage dealt by a cryp', description: 'increase the magic damage dealt by a construct',
colours: '1 Green 1 Blue', colours: '1 Green 1 Blue',
}, },
@ -182,7 +182,7 @@ module.exports = {
}, },
Banish: { Banish: {
description: 'target cryp is prevented from casting any skills and taking any damage', description: 'target construct is prevented from casting any skills and taking any damage',
colours: '1 Red 1 Green', colours: '1 Red 1 Green',
}, },
@ -198,7 +198,7 @@ module.exports = {
}, },
Buff: { Buff: {
description: 'increase target cryp speed', description: 'increase target construct speed',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
@ -213,42 +213,42 @@ module.exports = {
}, },
Curse: { Curse: {
description: 'target cryp takes increased magic damage', description: 'target construct takes increased magic damage',
colours: '2 Blue', colours: '2 Blue',
}, },
Debuff: { Debuff: {
description: 'reduce target cryp speed', description: 'reduce target construct speed',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
Decay: { Decay: {
description: 'afflict a cryp with a blue damage based damage over time debuff', description: 'afflict a construct with a blue damage based damage over time debuff',
colours: '1 Green 1 Blue', colours: '1 Green 1 Blue',
}, },
Empower: { Empower: {
description: 'increase the red damage dealt by a cryp', description: 'increase the red damage dealt by a construct',
colours: '2 Red', colours: '2 Red',
}, },
Haste: { Haste: {
description: 'magical skill that increases speed of target cryp', description: 'magical skill that increases speed of target construct',
colours: '1 Red 1 Blue', colours: '1 Red 1 Blue',
}, },
Heal: { Heal: {
description: 'heal a cryp with blue damage', description: 'heal a construct with blue damage',
colours: '2 Green', colours: '2 Green',
}, },
Hex: { Hex: {
description: 'magical bsed skill that prevents target cryp from using any skills', description: 'magical bsed skill that prevents target construct from using any skills',
colours: '1 Red 1 Blue', colours: '1 Red 1 Blue',
}, },
Hostility: { Hostility: {
description: 'magical bsed skill that prevents target cryp from using any skills', description: 'magical bsed skill that prevents target construct from using any skills',
colours: '2 Blue', colours: '2 Blue',
}, },
@ -263,12 +263,12 @@ module.exports = {
}, },
Purge: { Purge: {
description: 'remove magical buffs from target cryp', description: 'remove magical buffs from target construct',
colours: '2 Green', colours: '2 Green',
}, },
Purify: { Purify: {
description: 'remove magical debuffs from target cryp', description: 'remove magical debuffs from target construct',
colours: '1 Red 1 Green', colours: '1 Red 1 Green',
}, },
@ -292,17 +292,17 @@ module.exports = {
}, },
Shield: { Shield: {
description: 'grants immunity to magical skills to target cryp', description: 'grants immunity to magical skills to target construct',
colours: '1 Green 1 Blue', colours: '1 Green 1 Blue',
}, },
Silence: { Silence: {
description: 'prevent target cryp from casting magical skills', description: 'prevent target construct from casting magical skills',
colours: '1 Green 1 Blue', colours: '1 Green 1 Blue',
}, },
Siphon: { Siphon: {
description: 'siphon hp from target cryp with a blue damage based debuff', description: 'siphon hp from target construct with a blue damage based debuff',
colours: '1 Green 1 Blue', colours: '1 Green 1 Blue',
}, },
@ -311,7 +311,7 @@ module.exports = {
}, },
Slow: { Slow: {
description: 'magical skill that reduces speed of target cryp', description: 'magical skill that reduces speed of target construct',
colours: '1 Red 1 Green', colours: '1 Red 1 Green',
}, },
@ -331,13 +331,13 @@ module.exports = {
}, },
Stun: { Stun: {
description: 'red skill hat prevents target cryp from using any skills', description: 'red skill hat prevents target construct from using any skills',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
Taunt: { Taunt: {
description: 'Enemy skills will prioritise cryps with this skill active', description: 'Enemy skills will prioritise constructs with this skill active',
colours: '1 Red 1 Green', colours: '1 Red 1 Green',
}, },
@ -354,19 +354,19 @@ module.exports = {
SPECS: { SPECS: {
Damage: { Damage: {
description: 'Increase red / green / blue power stats cryp', description: 'Increase red / green / blue power stats construct',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
Hp: { Hp: {
description: 'Increases health of cryp', description: 'Increases health of construct',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
Speed: { Speed: {
description: 'Increases speed of cryp', description: 'Increases speed of construct',
upgrades: 'combine with 2 red / blue / green', upgrades: 'combine with 2 red / blue / green',
}, },
}, },

View File

@ -7,7 +7,7 @@ const Combat = require('./combat');
// const Background = require('./background'); // const Background = require('./background');
function renderCryps() { function renderConstructs() {
const config = { const config = {
type: Phaser.CANVAS, type: Phaser.CANVAS,
// backgroundColor: '#181818', // backgroundColor: '#181818',
@ -74,4 +74,4 @@ function renderCryps() {
return game; return game;
} }
module.exports = renderCryps; module.exports = renderConstructs;

View File

@ -1,49 +1,49 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const { TEXT, POSITIONS: { COMBAT }, COLOURS } = require('.././constants'); const { TEXT, POSITIONS: { COMBAT }, COLOURS } = require('.././constants');
const CRYP_MARGIN = COMBAT.crypMargin(); const CONSTRUCT_MARGIN = COMBAT.constructMargin();
const TEXT_MARGIN = COMBAT.textMargin(); const TEXT_MARGIN = COMBAT.textMargin();
const statBarDimensions = (team, iter, margin) => { const statBarDimensions = (team, iter, margin) => {
const statBarWidth = COMBAT.width() * 0.07; const statBarWidth = COMBAT.width() * 0.07;
const statBarHeight = TEXT_MARGIN / 1.5; const statBarHeight = TEXT_MARGIN / 1.5;
const statBarX = (COMBAT.width() - statBarWidth) * team; const statBarX = (COMBAT.width() - statBarWidth) * team;
const statBarY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CRYP_MARGIN * iter + COMBAT.height() * 0.07; const statBarY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07;
return { statBarX, statBarY, statBarWidth, statBarHeight }; return { statBarX, statBarY, statBarWidth, statBarHeight };
}; };
const statTextCoord = (team, iter, margin) => { const statTextCoord = (team, iter, margin) => {
const statTextX = team ? COMBAT.width() - COMBAT.width() * 0.075 : COMBAT.width() * 0.075; const statTextX = team ? COMBAT.width() - COMBAT.width() * 0.075 : COMBAT.width() * 0.075;
const statTextY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CRYP_MARGIN * iter + COMBAT.height() * 0.07; const statTextY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07;
return { statTextX, statTextY }; return { statTextX, statTextY };
}; };
class StatBar extends Phaser.GameObjects.Graphics { class StatBar extends Phaser.GameObjects.Graphics {
constructor(scene, cryp, type) { constructor(scene, construct, type) {
super(scene); super(scene);
this.crypObj = cryp; this.constructObj = construct;
this.type = type; this.type = type;
if (type === 'HP') { if (type === 'HP') {
this.val = this.crypObj.cryp.hp.value; this.val = this.constructObj.construct.hp.value;
this.max = this.crypObj.cryp.hp.max; this.max = this.constructObj.construct.hp.max;
this.margin = 0; this.margin = 0;
} else if (type === 'Red Shield') { } else if (type === 'Red Shield') {
this.val = this.crypObj.cryp.red_shield.value; this.val = this.constructObj.construct.red_shield.value;
this.max = this.crypObj.cryp.red_shield.max; this.max = this.constructObj.construct.red_shield.max;
this.margin = 1; this.margin = 1;
} else if (type === 'Blue Shield') { } else if (type === 'Blue Shield') {
this.val = this.crypObj.cryp.blue_shield.value; this.val = this.constructObj.construct.blue_shield.value;
this.max = this.crypObj.cryp.blue_shield.max; this.max = this.constructObj.construct.blue_shield.max;
this.margin = 2; this.margin = 2;
} else if (type === 'Evasion') { } else if (type === 'Evasion') {
this.val = this.crypObj.cryp.evasion.value; this.val = this.constructObj.construct.evasion.value;
this.max = this.crypObj.cryp.evasion.max; this.max = this.constructObj.construct.evasion.max;
this.margin = 3; this.margin = 3;
} }
const { statTextX, statTextY } = statTextCoord(cryp.team, cryp.iter, this.margin); const { statTextX, statTextY } = statTextCoord(construct.team, construct.iter, this.margin);
this.statText = scene.add.text(statTextX, statTextY, '', TEXT.NORMAL).setOrigin(cryp.team, 0); this.statText = scene.add.text(statTextX, statTextY, '', TEXT.NORMAL).setOrigin(construct.team, 0);
this.drawStatBar(); this.drawStatBar();
} }
@ -51,7 +51,7 @@ class StatBar extends Phaser.GameObjects.Graphics {
this.clear(); this.clear();
const { const {
statBarX, statBarY, statBarWidth, statBarHeight, statBarX, statBarY, statBarWidth, statBarHeight,
} = statBarDimensions(this.crypObj.team, this.crypObj.iter, this.margin); } = statBarDimensions(this.constructObj.team, this.constructObj.iter, this.margin);
this.statText.text = `${this.val.toString()} / ${this.max.toString()} ${this.type}`; this.statText.text = `${this.val.toString()} / ${this.max.toString()} ${this.type}`;
// Draw Black Border // Draw Black Border
this.fillStyle(COLOURS.BLACK); this.fillStyle(COLOURS.BLACK);
@ -78,7 +78,7 @@ class StatBar extends Phaser.GameObjects.Graphics {
} else { } else {
this.val = (this.val - value > this.max) ? this.max : this.val -= value; this.val = (this.val - value > this.max) ? this.max : this.val -= value;
} }
if (this.val === 0 && this.type === 'HP') this.crypObj.setKo(); if (this.val === 0 && this.type === 'HP') this.constructObj.setKo();
this.drawStatBar(); this.drawStatBar();
} }
} }

View File

@ -27,15 +27,15 @@ class GameList extends Phaser.Scene {
.setInteractive() .setInteractive()
.setOrigin(0); .setOrigin(0);
const TITLE = `${game.teams[0].cryps.map(c => c.name).join(', ')} - ${game.team_size}v${game.team_size}`; const TITLE = `${game.teams[0].constructs.map(c => c.name).join(', ')} - ${game.team_size}v${game.team_size}`;
this.add this.add
.text(gameBox.getCenter().x, gameBox.getCenter().y, TITLE, TEXT.NORMAL) .text(gameBox.getCenter().x, gameBox.getCenter().y, TITLE, TEXT.NORMAL)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
gameBox.on('pointerdown', () => { gameBox.on('pointerdown', () => {
const cryps = this.registry.get('cryps'); const constructs = this.registry.get('constructs');
const team = cryps.filter(c => c.active).map(c => c.id); const team = constructs.filter(c => c.active).map(c => c.id);
ws.sendGameJoin(game.id, team); ws.sendGameJoin(game.id, team);
}); });
}; };

View File

@ -20,7 +20,7 @@ class Header extends Phaser.Scene {
} }
create() { create() {
this.add.text(0, 0, 'cryps.gg', TEXT.HEADER); this.add.text(0, 0, 'constructs.gg', TEXT.HEADER);
} }
} }

View File

@ -1,14 +1,14 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const { remove } = require('lodash'); const { remove } = require('lodash');
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants'); const { TEXT, COLOURS, POSITIONS: { CONSTRUCT_LIST } } = require('./constants');
const genAvatar = require('./avatar'); const genAvatar = require('./avatar');
const { LineGroup, LineBox } = require('./elements/outline.rotate'); const { LineGroup, LineBox } = require('./elements/outline.rotate');
const ROW_HEIGHT = CRYP_LIST.height() * 0.1; const ROW_HEIGHT = CONSTRUCT_LIST.height() * 0.1;
const ROW_WIDTH = CRYP_LIST.width(); const ROW_WIDTH = CONSTRUCT_LIST.width();
const menuY = CRYP_LIST.height() * 0.8; const menuY = CONSTRUCT_LIST.height() * 0.8;
const KEY_MAP = [ const KEY_MAP = [
'keydown-ONE', 'keydown-ONE',
@ -18,41 +18,41 @@ const KEY_MAP = [
const NULL_UUID = '00000000-0000-0000-0000-000000000000'; const NULL_UUID = '00000000-0000-0000-0000-000000000000';
class HomeCrypList extends Phaser.Scene { class HomeConstructList extends Phaser.Scene {
constructor() { constructor() {
super({ key: 'HomeCryps' }); super({ key: 'HomeConstructs' });
} }
updateData(parent, key, data) { updateData(parent, key, data) {
if (key === 'crypList') { if (key === 'constructList') {
KEY_MAP.forEach(k => this.input.keyboard.removeListener(k)); KEY_MAP.forEach(k => this.input.keyboard.removeListener(k));
this.scene.restart(); this.scene.restart();
} }
} }
create() { create() {
// this.cameras.main.setViewport(CRYP_LIST.x(), CRYP_LIST.y(), CRYP_LIST.width(), CRYP_LIST.height()); // this.cameras.main.setViewport(CONSTRUCT_LIST.x(), CONSTRUCT_LIST.y(), CONSTRUCT_LIST.width(), CONSTRUCT_LIST.height());
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this);
const cryps = this.registry.get('crypList'); const constructs = this.registry.get('constructList');
const lineGroup = this.add.existing(new LineGroup(this)); const lineGroup = this.add.existing(new LineGroup(this));
if (!cryps) return true; if (!constructs) return true;
const ws = this.registry.get('ws'); const ws = this.registry.get('ws');
this.activeCryps = []; this.activeConstructs = [];
// We only display 3 cryps others can be viewed in cryp list (soon TM) // We only display 3 constructs others can be viewed in construct list (soon TM)
for (let i = 0; i < cryps.length; i += 1) { for (let i = 0; i < constructs.length; i += 1) {
const cryp = cryps[i]; const construct = constructs[i];
const BOX_WIDTH = Math.floor(ROW_WIDTH / 5); const BOX_WIDTH = Math.floor(ROW_WIDTH / 5);
const ROW_X = BOX_WIDTH * 2 * (i % 3); const ROW_X = BOX_WIDTH * 2 * (i % 3);
const ROW_Y = CRYP_LIST.y() + (Math.floor(i / 3)) * ROW_HEIGHT * 1.5; const ROW_Y = CONSTRUCT_LIST.y() + (Math.floor(i / 3)) * ROW_HEIGHT * 1.5;
const ACTIVE_FILL = 0.2; const ACTIVE_FILL = 0.2;
const FILL = Object.values(COLOURS)[i]; const FILL = Object.values(COLOURS)[i];
// Selection of cryps // Selection of constructs
// Cryp avatar and interaction box // Construct avatar and interaction box
const cReady = this.add const cReady = this.add
.rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL) .rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL)
.setInteractive() .setInteractive()
@ -60,11 +60,11 @@ class HomeCrypList extends Phaser.Scene {
cReady.setAlpha(0.2); cReady.setAlpha(0.2);
cReady.on('pointerdown', () => { cReady.on('pointerdown', () => {
lineGroup.clear(true, true); lineGroup.clear(true, true);
if (this.activeCryps.includes(cReady)) { if (this.activeConstructs.includes(cReady)) {
remove(this.activeCryps, n => n === cReady); remove(this.activeConstructs, n => n === cReady);
cReady.setAlpha(0.2); cReady.setAlpha(0.2);
} else { } else {
this.activeCryps.push(cReady); this.activeConstructs.push(cReady);
cReady.setAlpha(0.75); cReady.setAlpha(0.75);
lineGroup.add(this.add.existing( lineGroup.add(this.add.existing(
new LineBox(this, cReady.x, cReady.y, cReady.width, cReady.height, cReady.fillColor, 3) new LineBox(this, cReady.x, cReady.y, cReady.width, cReady.height, cReady.fillColor, 3)
@ -79,24 +79,24 @@ class HomeCrypList extends Phaser.Scene {
cReady.setFillStyle(FILL, ACTIVE_FILL); cReady.setFillStyle(FILL, ACTIVE_FILL);
}; };
cReady.cryp = cryp; cReady.construct = construct;
this.add.image( this.add.image(
cReady.getCenter().x, cReady.getCenter().x,
cReady.getCenter().y, cReady.getCenter().y,
'aztec', 'aztec',
genAvatar(cryp.name) genAvatar(construct.name)
); );
this.add.text(ROW_X + BOX_WIDTH, ROW_Y, cryp.name, TEXT.HEADER) this.add.text(ROW_X + BOX_WIDTH, ROW_Y, construct.name, TEXT.HEADER)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
} }
// Add Spawn Cryp Option // Add Spawn Construct Option
const spawn = this.add const spawn = this.add
.rectangle(ROW_WIDTH * 0.05, menuY, ROW_WIDTH * 0.2, ROW_HEIGHT * 0.5, 0x888888) .rectangle(ROW_WIDTH * 0.05, menuY, ROW_WIDTH * 0.2, ROW_HEIGHT * 0.5, 0x888888)
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', () => { .on('pointerdown', () => {
this.game.events.emit('CRYP_SPAWN'); this.game.events.emit('CONSTRUCT_SPAWN');
}); });
this.add this.add
.text(spawn.getCenter().x, spawn.getCenter().y, '+', TEXT.HEADER) .text(spawn.getCenter().x, spawn.getCenter().y, '+', TEXT.HEADER)
@ -107,9 +107,9 @@ class HomeCrypList extends Phaser.Scene {
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', () => { .on('pointerdown', () => {
const playerCryps = []; const playerConstructs = [];
this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); this.activeConstructs.forEach(obj => playerConstructs.push(obj.construct.id));
ws.sendPlayerCrypsSet(NULL_UUID, playerCryps); ws.sendPlayerConstructsSet(NULL_UUID, playerConstructs);
}); });
this.add this.add
.text(joinNormal.getCenter().x, joinNormal.getCenter().y, 'Join Normal', TEXT.HEADER) .text(joinNormal.getCenter().x, joinNormal.getCenter().y, 'Join Normal', TEXT.HEADER)
@ -120,9 +120,9 @@ class HomeCrypList extends Phaser.Scene {
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', () => { .on('pointerdown', () => {
const playerCryps = []; const playerConstructs = [];
this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); this.activeConstructs.forEach(obj => playerConstructs.push(obj.construct.id));
ws.sendInstanceJoin(playerCryps); ws.sendInstanceJoin(playerConstructs);
}); });
this.add this.add
.text(joinInstance.getCenter().x, joinInstance.getCenter().y, 'New Instance', TEXT.HEADER) .text(joinInstance.getCenter().x, joinInstance.getCenter().y, 'New Instance', TEXT.HEADER)
@ -139,4 +139,4 @@ class HomeCrypList extends Phaser.Scene {
} }
} }
module.exports = HomeCrypList; module.exports = HomeConstructList;

View File

@ -1,7 +1,7 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const HomeCryps = require('./home.cryps'); const HomeConstructs = require('./home.constructs');
const HomeNavigation = require('./home.navigation'); const HomeNavigation = require('./home.navigation');
const HomeRankings = require('./home.rankings'); const HomeRankings = require('./home.rankings');
@ -10,7 +10,7 @@ const HomeShop = require('./home.shop');
const HomeInstances = require('./home.instances'); const HomeInstances = require('./home.instances');
const FIXED_SCENES = [ const FIXED_SCENES = [
'HomeCryps', 'HomeConstructs',
'HomeNavigation', 'HomeNavigation',
]; ];
@ -31,7 +31,7 @@ class Home extends Phaser.Scene {
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this);
this.scene.manager.add('HomeCryps', HomeCryps, true); this.scene.manager.add('HomeConstructs', HomeConstructs, true);
this.scene.manager.add('HomeNavigation', HomeNavigation, true); this.scene.manager.add('HomeNavigation', HomeNavigation, true);

View File

@ -16,7 +16,7 @@ class ItemInfo extends Phaser.Scene {
} }
create(props) { create(props) {
const { item, cryp } = props; const { item, construct } = props;
if (!item) return false; if (!item) return false;
// Default item text // Default item text
@ -51,19 +51,19 @@ class ItemInfo extends Phaser.Scene {
.setWordWrapWidth(WIDTH * 0.75); .setWordWrapWidth(WIDTH * 0.75);
if (colours !== '') { if (colours !== '') {
this.add this.add
.text(X, Y + HEIGHT * 0.35, `Adds ${colours} to cryp`, TEXT.NORMAL) .text(X, Y + HEIGHT * 0.35, `Adds ${colours} to construct`, TEXT.NORMAL)
.setWordWrapWidth(WIDTH * 0.75); .setWordWrapWidth(WIDTH * 0.75);
} }
if (!cryp) return true; if (!construct) return true;
const ws = this.registry.get('ws'); const ws = this.registry.get('ws');
const { vbox } = this.registry.get('player'); const { vbox } = this.registry.get('player');
const unEquip = this.add.rectangle(X, UNEQUIP_Y, UNEQUIP_WIDTH, UNEQUIP_HEIGHT, 0x222222) const unEquip = this.add.rectangle(X, UNEQUIP_Y, UNEQUIP_WIDTH, UNEQUIP_HEIGHT, 0x222222)
.setOrigin(0, 0) .setOrigin(0, 0)
.setInteractive() .setInteractive()
.on('pointerdown', () => { .on('pointerdown', () => {
ws.sendVboxUnequip(vbox.instance, cryp.id, item); ws.sendVboxUnequip(vbox.instance, construct.id, item);
this.registry.set('crypStats', cryp); this.registry.set('constructStats', construct);
}); });
this.add.text(unEquip.getCenter().x, unEquip.getCenter().y, 'unequip', TEXT.HEADER) this.add.text(unEquip.getCenter().x, unEquip.getCenter().y, 'unequip', TEXT.HEADER)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);

View File

@ -109,8 +109,8 @@ class DeleteHitBox extends Phaser.GameObjects.Rectangle {
const itemCheckHitbox = (scene, pointer) => { const itemCheckHitbox = (scene, pointer) => {
const { list } = scene.scene.get('MenuCrypList').children; const { list } = scene.scene.get('MenuConstructList').children;
const hitboxes = list.filter(c => c.cryp) const hitboxes = list.filter(c => c.construct)
.concat(scene.children.list.filter(c => c instanceof CombinerHitBox || c instanceof DeleteHitBox)); .concat(scene.children.list.filter(c => c instanceof CombinerHitBox || c instanceof DeleteHitBox));
let found; let found;
@ -283,7 +283,7 @@ class ItemList extends Phaser.Scene {
// Check first for hitbox interaction // Check first for hitbox interaction
const hitBox = itemCheckHitbox(this, pointer); const hitBox = itemCheckHitbox(this, pointer);
if (hitBox) { if (hitBox) {
// hitbox can only be the combinerhitbox, deletehitbox or cryp avatar // hitbox can only be the combinerhitbox, deletehitbox or construct avatar
hitBox.itemDeselect(); hitBox.itemDeselect();
if (hitBox instanceof CombinerHitBox) { if (hitBox instanceof CombinerHitBox) {
if (hitBox.item === item) deallocate(item); if (hitBox.item === item) deallocate(item);
@ -291,7 +291,7 @@ class ItemList extends Phaser.Scene {
} else if (hitBox instanceof DeleteHitBox) { } else if (hitBox instanceof DeleteHitBox) {
ws.sendVboxReclaim(vbox.instance, item.index); ws.sendVboxReclaim(vbox.instance, item.index);
} else { } else {
ws.sendVboxApply(vbox.instance, hitBox.cryp.id, item.index); ws.sendVboxApply(vbox.instance, hitBox.construct.id, item.index);
deallocate(item); deallocate(item);
} return true; } return true;
} }

View File

@ -1,11 +1,11 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants'); const { TEXT, COLOURS, POSITIONS: { CONSTRUCT_LIST } } = require('./constants');
const genAvatar = require('./avatar'); const genAvatar = require('./avatar');
const Item = require('./elements/item'); const Item = require('./elements/item');
const BOX_WIDTH = Math.floor(CRYP_LIST.width()); const BOX_WIDTH = Math.floor(CONSTRUCT_LIST.width());
const BOX_HEIGHT = Math.floor(CRYP_LIST.height() / 3.34); const BOX_HEIGHT = Math.floor(CONSTRUCT_LIST.height() / 3.34);
const TEXT_MARGIN = 24; const TEXT_MARGIN = 24;
@ -15,113 +15,113 @@ const KEY_MAP = [
'keydown-THREE', 'keydown-THREE',
]; ];
class MenuCrypList extends Phaser.Scene { class MenuConstructList extends Phaser.Scene {
constructor() { constructor() {
super({ key: 'MenuCrypList' }); super({ key: 'MenuConstructList' });
} }
create() { create() {
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this);
const player = this.registry.get('player'); const player = this.registry.get('player');
if (player) this.drawCryps(player.cryps); if (player) this.drawConstructs(player.constructs);
} }
updateData(parent, key, data) { updateData(parent, key, data) {
if (key === 'player') { if (key === 'player') {
this.drawCryps(data.cryps); this.drawConstructs(data.constructs);
} }
} }
drawCryps(cryps) { drawConstructs(constructs) {
if (!cryps) return true; if (!constructs) return true;
if (this.crypGroup) this.crypGroup.destroy(true); if (this.constructGroup) this.constructGroup.destroy(true);
this.crypGroup = this.add.group(); this.constructGroup = this.add.group();
const addCryp = (cryp, i) => { const addConstruct = (construct, i) => {
const ROW_X = CRYP_LIST.x(); const ROW_X = CONSTRUCT_LIST.x();
const ROW_Y = CRYP_LIST.y() + BOX_HEIGHT * i * 1.1; const ROW_Y = CONSTRUCT_LIST.y() + BOX_HEIGHT * i * 1.1;
const ACTIVE_FILL = 0.2; const ACTIVE_FILL = 0.2;
const FILL = Object.values(COLOURS)[i]; const FILL = Object.values(COLOURS)[i];
// Selection of cryps // Selection of constructs
const selectFn = () => { const selectFn = () => {
this.registry.set('crypStats', cryp); this.registry.set('constructStats', construct);
}; };
// Cryp interaction box for adding items // Construct interaction box for adding items
const crypInteract = this.add const constructInteract = this.add
.rectangle(ROW_X, ROW_Y, BOX_WIDTH, BOX_HEIGHT, FILL, ACTIVE_FILL) .rectangle(ROW_X, ROW_Y, BOX_WIDTH, BOX_HEIGHT, FILL, ACTIVE_FILL)
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', selectFn); .on('pointerdown', selectFn);
crypInteract.itemSelect = () => { constructInteract.itemSelect = () => {
crypInteract.setFillStyle(COLOURS.SELECT); constructInteract.setFillStyle(COLOURS.SELECT);
}; };
crypInteract.itemDeselect = () => { constructInteract.itemDeselect = () => {
crypInteract.setFillStyle(FILL, ACTIVE_FILL); constructInteract.setFillStyle(FILL, ACTIVE_FILL);
}; };
crypInteract.cryp = cryp; constructInteract.construct = construct;
// Cryp Avatar // Construct Avatar
const { name } = cryp; const { name } = construct;
const crypImage = this.add.image( const constructImage = this.add.image(
crypInteract.getCenter().x - crypInteract.width / 4, constructInteract.getCenter().x - constructInteract.width / 4,
crypInteract.getCenter().y, constructInteract.getCenter().y,
'aztec', 'aztec',
genAvatar(name) genAvatar(name)
); );
// Add text info // Add text info
const yCrypTextAlgin = Math.floor(crypInteract.y + TEXT_MARGIN / 2); const yConstructTextAlgin = Math.floor(constructInteract.y + TEXT_MARGIN / 2);
const xCrypNameAlign = Math.floor(crypInteract.x + crypInteract.width * 1 / 10); const xConstructNameAlign = Math.floor(constructInteract.x + constructInteract.width * 1 / 10);
const crypInfoText = this.add.text(xCrypNameAlign, yCrypTextAlgin, name, TEXT.HEADER); const constructInfoText = this.add.text(xConstructNameAlign, yConstructTextAlgin, name, TEXT.HEADER);
const colourText = (c, j) => { const colourText = (c, j) => {
// Placeholder for when gems are implemented // Placeholder for when gems are implemented
const gemText = this.add.text(crypInteract.x + crypInteract.width * (j + 3) / 6, yCrypTextAlgin, `${c[0]} - ${c[1]}`, TEXT.HEADER); const gemText = this.add.text(constructInteract.x + constructInteract.width * (j + 3) / 6, yConstructTextAlgin, `${c[0]} - ${c[1]}`, TEXT.HEADER);
this.crypGroup.add(gemText); this.constructGroup.add(gemText);
}; };
const { red, green, blue } = cryp.colours; const { red, green, blue } = construct.colours;
const CRYP_COLOURS = [ const CONSTRUCT_COLOURS = [
['R', red], ['R', red],
['G', green], ['G', green],
['B', blue], ['B', blue],
]; ];
CRYP_COLOURS.forEach(colourText); CONSTRUCT_COLOURS.forEach(colourText);
this.crypGroup.addMultiple([crypInteract, crypImage, crypInfoText]); this.constructGroup.addMultiple([constructInteract, constructImage, constructInfoText]);
const crypSkill = (stat, j) => { const constructSkill = (stat, j) => {
const SKILL_WIDTH = Math.floor(BOX_WIDTH / 2); const SKILL_WIDTH = Math.floor(BOX_WIDTH / 2);
const SKILL_HEIGHT = Math.floor(BOX_HEIGHT / 8); const SKILL_HEIGHT = Math.floor(BOX_HEIGHT / 8);
const SKILL_X = crypInteract.getCenter().x + crypInteract.width / 4; const SKILL_X = constructInteract.getCenter().x + constructInteract.width / 4;
const SKILL_Y = crypInteract.y + SKILL_HEIGHT * 1.15 * (j + 1.6); const SKILL_Y = constructInteract.y + SKILL_HEIGHT * 1.15 * (j + 1.6);
const itemObj = new Item(this, stat.skill, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT); const itemObj = new Item(this, stat.skill, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT);
this.add.existing(itemObj); this.add.existing(itemObj);
itemObj.setInteractive(); itemObj.setInteractive();
const itemInfo = { item: stat.skill, cryp }; const itemInfo = { item: stat.skill, construct };
itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo));
this.crypGroup.add(itemObj); this.constructGroup.add(itemObj);
}; };
cryp.skills.forEach(crypSkill); construct.skills.forEach(constructSkill);
const crypSpec = (spec, j) => { const constructSpec = (spec, j) => {
const SKILL_WIDTH = Math.floor(BOX_WIDTH * 0.15); const SKILL_WIDTH = Math.floor(BOX_WIDTH * 0.15);
const SKILL_HEIGHT = Math.floor(BOX_HEIGHT * 0.2); const SKILL_HEIGHT = Math.floor(BOX_HEIGHT * 0.2);
const SKILL_X = Math.floor(crypInteract.x + BOX_WIDTH * (0.6 + j) * 0.175); const SKILL_X = Math.floor(constructInteract.x + BOX_WIDTH * (0.6 + j) * 0.175);
const SKILL_Y = Math.floor(crypInteract.y + BOX_HEIGHT * 0.875); const SKILL_Y = Math.floor(constructInteract.y + BOX_HEIGHT * 0.875);
const itemObj = new Item(this, spec, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT); const itemObj = new Item(this, spec, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT);
itemObj.setInteractive(); itemObj.setInteractive();
const itemInfo = { item: spec, cryp }; const itemInfo = { item: spec, construct };
itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo));
this.add.existing(itemObj); this.add.existing(itemObj);
this.crypGroup.add(itemObj); this.constructGroup.add(itemObj);
}; };
cryp.specs.forEach(crypSpec); construct.specs.forEach(constructSpec);
}; };
cryps.forEach(addCryp); constructs.forEach(addConstruct);
return true; return true;
} }
@ -134,4 +134,4 @@ class MenuCrypList extends Phaser.Scene {
} }
} }
module.exports = MenuCrypList; module.exports = MenuConstructList;

View File

@ -1,7 +1,7 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
// Scenes constantly showing // Scenes constantly showing
const MenuCrypList = require('./menu.cryps.list'); const MenuConstructList = require('./menu.constructs.list');
const MenuNavigation = require('./menu.navigation'); const MenuNavigation = require('./menu.navigation');
const ItemList = require('./item.list'); const ItemList = require('./item.list');
// Scenes which change depending on menu context // Scenes which change depending on menu context
@ -11,7 +11,7 @@ const StatSheet = require('./statsheet');
const ItemInfo = require('./item.info'); const ItemInfo = require('./item.info');
const FIXED_MENU_SCENES = [ const FIXED_MENU_SCENES = [
'MenuCrypList', 'MenuConstructList',
'MenuNavigation', 'MenuNavigation',
'ItemList', 'ItemList',
]; ];
@ -37,7 +37,7 @@ class Menu extends Phaser.Scene {
this.registry.get('ws').sendPlayerState(player.instance); this.registry.get('ws').sendPlayerState(player.instance);
// When we load the menu request the latest items // When we load the menu request the latest items
// Item list will restart when the data comes in // Item list will restart when the data comes in
this.scene.manager.add('MenuCrypList', MenuCrypList, true); this.scene.manager.add('MenuConstructList', MenuConstructList, true);
this.scene.manager.add('MenuNavigation', MenuNavigation, true); this.scene.manager.add('MenuNavigation', MenuNavigation, true);
this.scene.manager.add('ItemList', ItemList, true); this.scene.manager.add('ItemList', ItemList, true);
this.registry.set('inMenu', true); this.registry.set('inMenu', true);
@ -53,7 +53,7 @@ class Menu extends Phaser.Scene {
case 'home': return this.cleanUp(); case 'home': return this.cleanUp();
case 'zone': return this.newMainScene('Zones', Zones, data); case 'zone': return this.newMainScene('Zones', Zones, data);
case 'gameList': return this.newMainScene('GameList', GameList, data); case 'gameList': return this.newMainScene('GameList', GameList, data);
case 'crypStats': return this.newMainScene('StatSheet', StatSheet, data); case 'constructStats': return this.newMainScene('StatSheet', StatSheet, data);
case 'itemInfo': return this.newMainScene('ItemInfo', ItemInfo, data); case 'itemInfo': return this.newMainScene('ItemInfo', ItemInfo, data);
default: return false; default: return false;
} }

View File

@ -21,8 +21,8 @@ class DeleteHitBox extends Phaser.GameObjects.Rectangle {
} }
const itemCheckHitbox = (scene, pointer) => { const itemCheckHitbox = (scene, pointer) => {
const { list } = scene.scene.get('MenuCrypList').children; const { list } = scene.scene.get('MenuConstructList').children;
const hitboxes = list.filter(c => c.cryp) const hitboxes = list.filter(c => c.construct)
.concat(scene.children.list.filter(c => c instanceof DeleteHitBox)); .concat(scene.children.list.filter(c => c instanceof DeleteHitBox));
let found; let found;
@ -47,12 +47,12 @@ class StatSheet extends Phaser.Scene {
if (key === 'player') { if (key === 'player') {
console.log('grep'); console.log('grep');
console.log(data); console.log(data);
const cryp = data.cryps.find(c => c.id === this.cryp.id); const construct = data.constructs.find(c => c.id === this.construct.id);
this.scene.restart(cryp); this.scene.restart(construct);
} }
} }
create(cryp) { create(construct) {
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
// const ws = this.registry.get('ws'); // const ws = this.registry.get('ws');
@ -60,7 +60,7 @@ class StatSheet extends Phaser.Scene {
if (!player) return false; if (!player) return false;
// const { vbox } = player; // const { vbox } = player;
this.cryp = cryp; this.construct = construct;
/* /*
const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6)); const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6));
@ -68,25 +68,25 @@ class StatSheet extends Phaser.Scene {
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
*/ */
this.add.text(X, Y, cryp.name, TEXT.HEADER); this.add.text(X, Y, construct.name, TEXT.HEADER);
const crypStat = (stat, i) => { const constructStat = (stat, i) => {
const STAT_X = X; const STAT_X = X;
const STAT_Y = Y + (i + 2) * TEXT_MARGIN; const STAT_Y = Y + (i + 2) * TEXT_MARGIN;
this.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base} -> ${stat.value}`, TEXT.NORMAL); this.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base} -> ${stat.value}`, TEXT.NORMAL);
}; };
const CRYP_STATS = [ const CONSTRUCT_STATS = [
cryp.hp, construct.hp,
cryp.red_shield, construct.red_shield,
cryp.blue_shield, construct.blue_shield,
cryp.evasion, construct.evasion,
cryp.red_damage, construct.red_damage,
cryp.blue_damage, construct.blue_damage,
cryp.speed, construct.speed,
]; ];
CRYP_STATS.forEach(crypStat); CONSTRUCT_STATS.forEach(constructStat);
/* /*
const knownSkill = (skill, i) => { const knownSkill = (skill, i) => {
const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i; const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i;
@ -96,7 +96,7 @@ class StatSheet extends Phaser.Scene {
this.input.setDraggable(itemObj); this.input.setDraggable(itemObj);
this.add.existing(itemObj); this.add.existing(itemObj);
}; };
cryp.skills.forEach(knownSkill); construct.skills.forEach(knownSkill);
this.add.text(X + WIDTH * 0.35, Y, 'Skills', TEXT.HEADER); this.add.text(X + WIDTH * 0.35, Y, 'Skills', TEXT.HEADER);
this.add.text(X + WIDTH * 0.35, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER); this.add.text(X + WIDTH * 0.35, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER);
@ -108,7 +108,7 @@ class StatSheet extends Phaser.Scene {
this.input.setDraggable(itemObj); this.input.setDraggable(itemObj);
this.add.existing(itemObj); this.add.existing(itemObj);
}; };
cryp.specs.forEach(knownSpec); construct.specs.forEach(knownSpec);
this.input.on('drag', (pointer, item, dragX, dragY) => { this.input.on('drag', (pointer, item, dragX, dragY) => {
@ -126,7 +126,7 @@ class StatSheet extends Phaser.Scene {
if (hitBox) { if (hitBox) {
hitBox.itemDeselect(); hitBox.itemDeselect();
// add socket function for unlearn here // add socket function for unlearn here
ws.sendVboxUnequip(vbox.instance, cryp.id, item.item); ws.sendVboxUnequip(vbox.instance, construct.id, item.item);
} }
return true; return true;
}); });

View File

@ -70,7 +70,7 @@ class Zones extends Phaser.Scene {
// Check cursor hasn't significantly moved during point allocation // Check cursor hasn't significantly moved during point allocation
// If panning and mouse release is on node it won't allocate // If panning and mouse release is on node it won't allocate
if (gameObjects[0] instanceof Node) { if (gameObjects[0] instanceof Node) {
const team = this.registry.get('cryps').filter(c => c.active).map(c => c.id); const team = this.registry.get('constructs').filter(c => c.active).map(c => c.id);
if (gameObjects[0].success) return false; if (gameObjects[0].success) return false;
this.registry.get('ws').sendZoneJoin(zoneId, gameObjects[0].id, team); this.registry.get('ws').sendZoneJoin(zoneId, gameObjects[0].id, team);
} }

View File

@ -2,7 +2,7 @@ const toast = require('izitoast');
const cbor = require('borc'); const cbor = require('borc');
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://cryps.gg/ws' : 'ws://localhost:40000'; const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://constructs.gg/ws' : 'ws://localhost:40000';
function errorToast(err) { function errorToast(err) {
console.error(err); console.error(err);
@ -41,8 +41,8 @@ function createSocket(events) {
send({ method: 'account_demo', params: {} }); send({ method: 'account_demo', params: {} });
} }
function sendAccountCryps() { function sendAccountConstructs() {
send({ method: 'account_cryps', params: {} }); send({ method: 'account_constructs', params: {} });
} }
function sendAccountInstances() { function sendAccountInstances() {
@ -53,40 +53,40 @@ function createSocket(events) {
send({ method: 'account_zone', params: {} }); send({ method: 'account_zone', params: {} });
} }
function sendCrypSpawn(name) { function sendConstructSpawn(name) {
send({ method: 'cryp_spawn', params: { name } }); send({ method: 'construct_spawn', params: { name } });
} }
function sendCrypLearn(id, skill) { function sendConstructLearn(id, skill) {
send({ method: 'cryp_learn', params: { id, skill } }); send({ method: 'construct_learn', params: { id, skill } });
} }
function sendCrypForget(id, skill) { function sendConstructForget(id, skill) {
send({ method: 'cryp_forget', params: { id, skill } }); send({ method: 'construct_forget', params: { id, skill } });
} }
function sendGameState(id) { function sendGameState(id) {
send({ method: 'game_state', params: { id } }); send({ method: 'game_state', params: { id } });
} }
function sendGamePve(crypIds, mode) { function sendGamePve(constructIds, mode) {
send({ method: 'game_pve', params: { cryp_ids: crypIds, mode } }); send({ method: 'game_pve', params: { construct_ids: constructIds, mode } });
} }
function sendGamePvp(crypIds) { function sendGamePvp(constructIds) {
send({ method: 'game_pvp', params: { cryp_ids: crypIds } }); send({ method: 'game_pvp', params: { construct_ids: constructIds } });
} }
function sendGameJoin(gameId, crypIds) { function sendGameJoin(gameId, constructIds) {
send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } }); send({ method: 'game_join', params: { game_id: gameId, construct_ids: constructIds } });
} }
function sendSpecForget(id, spec) { function sendSpecForget(id, spec) {
send({ method: 'cryp_unspec', params: { id, spec } }); send({ method: 'construct_unspec', params: { id, spec } });
} }
function sendPlayerCrypsSet(instanceId, crypIds) { function sendPlayerConstructsSet(instanceId, constructIds) {
send({ method: 'player_cryps_set', params: { instance_id: instanceId, cryp_ids: crypIds } }); send({ method: 'player_constructs_set', params: { instance_id: instanceId, construct_ids: constructIds } });
} }
function sendPlayerState(instanceId) { function sendPlayerState(instanceId) {
@ -97,12 +97,12 @@ function createSocket(events) {
send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group, index } }); send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group, index } });
} }
function sendVboxApply(instanceId, crypId, index) { function sendVboxApply(instanceId, constructId, index) {
send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } }); send({ method: 'player_vbox_apply', params: { instance_id: instanceId, construct_id: constructId, index } });
} }
function sendVboxUnequip(instanceId, crypId, target) { function sendVboxUnequip(instanceId, constructId, target) {
send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } }); send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, construct_id: constructId, target } });
} }
function sendVboxDiscard(instanceId) { function sendVboxDiscard(instanceId) {
@ -117,18 +117,18 @@ function createSocket(events) {
send({ method: 'player_vbox_reclaim', params: { instance_id: instanceId, index } }); send({ method: 'player_vbox_reclaim', params: { instance_id: instanceId, index } });
} }
function sendGameSkill(gameId, crypId, targetCrypId, skill) { function sendGameSkill(gameId, constructId, targetConstructId, skill) {
send({ send({
method: 'game_skill', method: 'game_skill',
params: { params: {
game_id: gameId, cryp_id: crypId, target_cryp_id: targetCrypId, skill, game_id: gameId, construct_id: constructId, target_construct_id: targetConstructId, skill,
}, },
}); });
events.setActiveSkill(null); events.setActiveSkill(null);
} }
function sendGameTarget(gameId, crypId, skillId) { function sendGameTarget(gameId, constructId, skillId) {
send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } }); send({ method: 'game_target', params: { game_id: gameId, construct_id: constructId, skill_id: skillId } });
events.setActiveSkill(null); events.setActiveSkill(null);
} }
@ -136,16 +136,16 @@ function createSocket(events) {
send({ method: 'zone_create', params: {} }); send({ method: 'zone_create', params: {} });
} }
function sendZoneJoin(zoneId, nodeId, crypIds) { function sendZoneJoin(zoneId, nodeId, constructIds) {
send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, cryp_ids: crypIds } }); send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, construct_ids: constructIds } });
} }
function sendZoneClose(zoneId) { function sendZoneClose(zoneId) {
send({ method: 'zone_close', params: { zone_id: zoneId } }); send({ method: 'zone_close', params: { zone_id: zoneId } });
} }
function sendInstanceJoin(cryps) { function sendInstanceJoin(constructs) {
send({ method: 'instance_join', params: { cryp_ids: cryps, pve: true } }); send({ method: 'instance_join', params: { construct_ids: constructs, pve: true } });
} }
function sendInstanceReady(instanceId) { function sendInstanceReady(instanceId) {
@ -165,7 +165,7 @@ function createSocket(events) {
account = login; account = login;
events.setAccount(login); events.setAccount(login);
sendAccountCryps(); sendAccountConstructs();
} }
function accountInstanceList(res) { function accountInstanceList(res) {
@ -173,9 +173,9 @@ function createSocket(events) {
events.setInstanceList(instanceList); events.setInstanceList(instanceList);
} }
function accountCryps(response) { function accountConstructs(response) {
const [structName, cryps] = response; const [structName, constructs] = response;
events.setCrypList(cryps); events.setConstructList(constructs);
} }
function gameState(response) { function gameState(response) {
@ -183,8 +183,8 @@ function createSocket(events) {
events.setGame(game); events.setGame(game);
} }
function crypSpawn(response) { function constructSpawn(response) {
const [structName, cryp] = response; const [structName, construct] = response;
} }
function gamePve(response) { function gamePve(response) {
@ -213,14 +213,14 @@ function createSocket(events) {
// when the server sends a reply it will have one of these message types // when the server sends a reply it will have one of these message types
// this object wraps the reply types to a function // this object wraps the reply types to a function
const handlers = { const handlers = {
cryp_spawn: crypSpawn, construct_spawn: constructSpawn,
cryp_forget: () => true, construct_forget: () => true,
cryp_learn: () => true, construct_learn: () => true,
game_pve: gamePve, game_pve: gamePve,
game_state: gameState, game_state: gameState,
account_login: accountLogin, account_login: accountLogin,
account_create: accountLogin, account_create: accountLogin,
account_cryps: accountCryps, account_constructs: accountConstructs,
account_instances: accountInstanceList, account_instances: accountInstanceList,
instance_scores: instanceScores, instance_scores: instanceScores,
zone_create: res => console.log(res), zone_create: res => console.log(res),
@ -232,9 +232,9 @@ function createSocket(events) {
function errHandler(error) { function errHandler(error) {
switch (error) { switch (error) {
case 'no active zone': return sendZoneCreate(); case 'no active zone': return sendZoneCreate();
case 'no cryps selected': return events.errorPrompt('select_cryps'); case 'no constructs selected': return events.errorPrompt('select_constructs');
case 'node requirements not met': return events.errorPrompt('complete_nodes'); case 'node requirements not met': return events.errorPrompt('complete_nodes');
case 'cryp at max skills (4)': return events.errorPrompt('max_skills'); case 'construct at max skills (4)': return events.errorPrompt('max_skills');
default: return errorToast(error); default: return errorToast(error);
@ -301,7 +301,7 @@ function createSocket(events) {
sendAccountLogin, sendAccountLogin,
sendAccountCreate, sendAccountCreate,
sendAccountDemo, sendAccountDemo,
sendAccountCryps, sendAccountConstructs,
sendAccountInstances, sendAccountInstances,
sendAccountZone, sendAccountZone,
sendGameState, sendGameState,
@ -310,9 +310,9 @@ function createSocket(events) {
sendGameJoin, sendGameJoin,
sendGameSkill, sendGameSkill,
sendGameTarget, sendGameTarget,
sendCrypSpawn, sendConstructSpawn,
sendCrypLearn, sendConstructLearn,
sendCrypForget, sendConstructForget,
sendSpecForget, sendSpecForget,
sendZoneCreate, sendZoneCreate,
sendZoneJoin, sendZoneJoin,
@ -320,7 +320,7 @@ function createSocket(events) {
sendInstanceJoin, sendInstanceJoin,
sendInstanceReady, sendInstanceReady,
sendInstanceScores, sendInstanceScores,
sendPlayerCrypsSet, sendPlayerConstructsSet,
sendPlayerState, sendPlayerState,
sendVboxAccept, sendVboxAccept,
sendVboxApply, sendVboxApply,

View File

@ -9,34 +9,34 @@ function noMore(instance, thisToast) {
} }
const WELCOME_MESSAGE = ` const WELCOME_MESSAGE = `
Welcome to cryps.gg Welcome to constructs.gg
Enter a username and password and press register to sign up, Enter a username and password and press register to sign up,
or just press DEMO to quick start. or just press DEMO to quick start.
`; `;
const HOMEPAGE_MESSAGE = ` const HOMEPAGE_MESSAGE = `
This homepage shows your cryps, joinable online games, PVE options and your items.\n This homepage shows your constructs, joinable online games, PVE options and your items.\n
If you have no cryps yet, press SPAWN and give your cryp a name to create one. If you have no constructs yet, press SPAWN and give your construct a name to create one.
Once you have made a cryp, click on them to visit their stat page and teach them some SKILLS. Once you have made a construct, click on them to visit their stat page and teach them some SKILLS.
The stat page also has descriptions of each skill and their effects. The stat page also has descriptions of each skill and their effects.
cryps have 3 basic stats: hp, red damage and magic damage. constructs have 3 basic stats: hp, red damage and magic damage.
Toggle whether a cryp is selected for your team by clicking the coloured stripes next to the cryp or press 1,2,3. Toggle whether a construct is selected for your team by clicking the coloured stripes next to the construct or press 1,2,3.
Once you have a team ready press the New PVE Game button to start playing. Once you have a team ready press the New PVE Game button to start playing.
`; `;
const SKILL_PHASE_MESSAGE = ` const SKILL_PHASE_MESSAGE = `
A cryps battle has two main phases. This first phase is called the SKILL PHASE. A constructs battle has two main phases. This first phase is called the SKILL PHASE.
Your cryps are positioned on the left, your opponent's are on the right. Your constructs are positioned on the left, your opponent's are on the right.
In the centre are your cryps' SKILLS, grayed out SKILLS are currently ON COOLDOWN. In the centre are your constructs' SKILLS, grayed out SKILLS are currently ON COOLDOWN.
A skill's cooldown reduces on every turn that cryp does not use a skill with a cooldown. A skill's cooldown reduces on every turn that construct does not use a skill with a cooldown.
For the moment, drag ATTACK onto the opponent team to have your cryps attack them with red damage. For the moment, drag ATTACK onto the opponent team to have your constructs attack them with red damage.
`; `;
// const TARGET_PHASE_MESSAGE = ` // const TARGET_PHASE_MESSAGE = `
// This phase is the TARGET PHASE. // This phase is the TARGET PHASE.
// In cryps you do not directly attack your opponent's cryps, you attack the opponent as a team // In constructs you do not directly attack your opponent's constructs, you attack the opponent as a team
// and you and your opponent choose which cryp is the TARGET of each ability. // and you and your opponent choose which construct is the TARGET of each ability.
// Drag the incoming ATTACKS from the right hand side onto your own cryps. // Drag the incoming ATTACKS from the right hand side onto your own constructs.
// It's wise to spread the damage around! // It's wise to spread the damage around!
// `; // `;
@ -44,9 +44,9 @@ const RESOLUTION_PHASE_MESSAGE = `
The second phase is called the RESOLUTION PHASE. The second phase is called the RESOLUTION PHASE.
This phase happens automatically, every skill is RESOLVED in order of its SPEED. This phase happens automatically, every skill is RESOLVED in order of its SPEED.
This is important because attacks only RESOLVE while their caster is still able to use the skill, This is important because attacks only RESOLVE while their caster is still able to use the skill,
a fast skill that does a small amount of damage may KO an opponent cryp, causing any SKILLS a fast skill that does a small amount of damage may KO an opponent construct, causing any SKILLS
they have used to no longer RESOLVE! they have used to no longer RESOLVE!
Another example of this is the skill STUN. STUN causes an opponent cryp to be unable to use any Another example of this is the skill STUN. STUN causes an opponent construct to be unable to use any
abilities for TWO TURNS including the turn it resolves on. In other words it lasts for the rest of the turn it resolves on abilities for TWO TURNS including the turn it resolves on. In other words it lasts for the rest of the turn it resolves on
and the whole next turn. and the whole next turn.
Try it now! Try it now!
@ -54,10 +54,10 @@ Try it now!
const FINISH_PHASE_MESSAGE = ` const FINISH_PHASE_MESSAGE = `
gg! The game has now concluded, if you were the winner you have been awarded with a STAT REROLL ITEM. gg! The game has now concluded, if you were the winner you have been awarded with a STAT REROLL ITEM.
You can use this to reroll a stat on a cryp which may be lacking. You can use this to reroll a stat on a construct which may be lacking.
A good metric is that if a stat is more than 1/2 of its STAMINA that's a good roll. A good metric is that if a stat is more than 1/2 of its STAMINA that's a good roll.
Now that you have learned the basics, press BACKSPACE to return to the main menu Now that you have learned the basics, press BACKSPACE to return to the main menu
and experiment with some combinations of SKILLS or replace the ones your cryps know in the STAT PAGE. and experiment with some combinations of SKILLS or replace the ones your constructs know in the STAT PAGE.
glhf! glhf!
`; `;

View File

@ -1 +1 @@
DATABASE_URL=postgres://cryps:craftbeer@localhost/cryps DATABASE_URL=postgres://constructs:craftbeer@localhost/constructs

View File

@ -1,5 +1,5 @@
[package] [package]
name = "cryps" name = "constructs"
version = "0.1.0" version = "0.1.0"
authors = ["ntr <ntr@smokestack.io>"] authors = ["ntr <ntr@smokestack.io>"]
@ -13,7 +13,7 @@ serde_cbor = "0.9"
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
tungstenite = "0.6" tungstenite = "0.6"
bcrypt = "0.2" bconstructt = "0.2"
dotenv = "0.9.0" dotenv = "0.9.0"
postgres = { version = "0.15", features = ["with-uuid"] } postgres = { version = "0.15", features = ["with-uuid"] }

View File

@ -1,5 +1,5 @@
use uuid::Uuid; use uuid::Uuid;
use bcrypt::{hash, verify}; use bconstructt::{hash, verify};
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rand::distributions::Alphanumeric; use rand::distributions::Alphanumeric;
use std::iter; use std::iter;
@ -9,7 +9,7 @@ use postgres::transaction::Transaction;
use rpc::{AccountCreateParams, AccountLoginParams}; use rpc::{AccountCreateParams, AccountLoginParams};
use cryp::{Cryp, cryp_recover}; use construct::{Construct, construct_recover};
use instance::{Instance, instance_delete}; use instance::{Instance, instance_delete};
use failure::Error; use failure::Error;
@ -155,34 +155,34 @@ pub fn account_login(params: AccountLoginParams, tx: &mut Transaction) -> Result
return Ok(account); return Ok(account);
} }
pub fn account_cryps(tx: &mut Transaction, account: &Account) -> Result<Vec<Cryp>, Error> { pub fn account_constructs(tx: &mut Transaction, account: &Account) -> Result<Vec<Construct>, Error> {
let query = " let query = "
SELECT data SELECT data
FROM cryps FROM constructs
WHERE account = $1; WHERE account = $1;
"; ";
let result = tx let result = tx
.query(query, &[&account.id])?; .query(query, &[&account.id])?;
let cryps: Result<Vec<Cryp>, _> = result.iter() let constructs: Result<Vec<Construct>, _> = result.iter()
.map(|row| { .map(|row| {
let cryp_bytes: Vec<u8> = row.get(0); let construct_bytes: Vec<u8> = row.get(0);
match from_slice::<Cryp>(&cryp_bytes) { match from_slice::<Construct>(&construct_bytes) {
Ok(c) => Ok(c), Ok(c) => Ok(c),
Err(_e) => cryp_recover(cryp_bytes, tx), Err(_e) => construct_recover(construct_bytes, tx),
} }
}) })
.collect(); .collect();
// catch any errors // catch any errors
if cryps.is_err() { if constructs.is_err() {
return Err(err_msg("could not deserialize a cryp")); return Err(err_msg("could not deserialize a construct"));
} }
let mut cryps = cryps.unwrap(); let mut constructs = constructs.unwrap();
cryps.sort_by_key(|c| c.id); constructs.sort_by_key(|c| c.id);
return Ok(cryps); return Ok(constructs);
} }
pub fn account_instances(tx: &mut Transaction, account: &Account) -> Result<Vec<Instance>, Error> { pub fn account_instances(tx: &mut Transaction, account: &Account) -> Result<Vec<Instance>, Error> {

View File

@ -8,7 +8,7 @@ use failure::Error;
use failure::err_msg; use failure::err_msg;
use account::{Account}; use account::{Account};
use rpc::{CrypSpawnParams}; use rpc::{ConstructSpawnParams};
use skill::{Skill, Cooldown, Effect, Cast, Colour, Immunity, Disable, Event}; use skill::{Skill, Cooldown, Effect, Cast, Colour, Immunity, Disable, Event};
use spec::{Spec}; use spec::{Spec};
use item::{Item}; use item::{Item};
@ -25,15 +25,15 @@ impl Colours {
Colours { red: 0, green: 0, blue: 0 } Colours { red: 0, green: 0, blue: 0 }
} }
pub fn from_cryp(cryp: &Cryp) -> Colours { pub fn from_construct(construct: &Construct) -> Colours {
let mut count = Colours::new(); let mut count = Colours::new();
for spec in cryp.specs.iter() { for spec in construct.specs.iter() {
let v = Item::from(*spec); let v = Item::from(*spec);
v.colours(&mut count); v.colours(&mut count);
} }
for cs in cryp.skills.iter() { for cs in construct.skills.iter() {
let v = Item::from(cs.skill); let v = Item::from(cs.skill);
v.colours(&mut count); v.colours(&mut count);
} }
@ -44,15 +44,15 @@ impl Colours {
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub struct CrypSkill { pub struct ConstructSkill {
pub skill: Skill, pub skill: Skill,
pub self_targeting: bool, pub self_targeting: bool,
pub cd: Cooldown, pub cd: Cooldown,
} }
impl CrypSkill { impl ConstructSkill {
pub fn new(skill: Skill) -> CrypSkill { pub fn new(skill: Skill) -> ConstructSkill {
CrypSkill { ConstructSkill {
skill, skill,
self_targeting: skill.self_targeting(), self_targeting: skill.self_targeting(),
cd: skill.base_cd(), cd: skill.base_cd(),
@ -69,24 +69,24 @@ pub enum EffectMeta {
} }
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub struct CrypEffect { pub struct ConstructEffect {
pub effect: Effect, pub effect: Effect,
pub duration: u8, pub duration: u8,
pub meta: Option<EffectMeta>, pub meta: Option<EffectMeta>,
pub tick: Option<Cast>, pub tick: Option<Cast>,
} }
impl CrypEffect { impl ConstructEffect {
pub fn new(effect: Effect, duration: u8) -> CrypEffect { pub fn new(effect: Effect, duration: u8) -> ConstructEffect {
CrypEffect { effect, duration, meta: None, tick: None } ConstructEffect { effect, duration, meta: None, tick: None }
} }
pub fn set_tick(mut self, tick: Cast) -> CrypEffect { pub fn set_tick(mut self, tick: Cast) -> ConstructEffect {
self.tick = Some(tick); self.tick = Some(tick);
self self
} }
pub fn set_meta(mut self, meta: EffectMeta) -> CrypEffect { pub fn set_meta(mut self, meta: EffectMeta) -> ConstructEffect {
self.meta = Some(meta); self.meta = Some(meta);
self self
} }
@ -119,20 +119,20 @@ pub enum Stat {
} }
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub struct CrypStat { pub struct ConstructStat {
base: u64, base: u64,
value: u64, value: u64,
max: u64, max: u64,
pub stat: Stat, pub stat: Stat,
} }
impl CrypStat { impl ConstructStat {
// pub fn set(&mut self, v: u64, specs: &Vec<Spec>) -> &mut CrypStat { // pub fn set(&mut self, v: u64, specs: &Vec<Spec>) -> &mut ConstructStat {
// self.base = v; // self.base = v;
// self.recalculate(specs) // self.recalculate(specs)
// } // }
pub fn recalculate(&mut self, specs: &Vec<Spec>, cryp_colours: &Colours, player_colours: &Colours) -> &mut CrypStat { pub fn recalculate(&mut self, specs: &Vec<Spec>, construct_colours: &Colours, player_colours: &Colours) -> &mut ConstructStat {
let specs = specs let specs = specs
.iter() .iter()
.filter(|s| s.affects().contains(&self.stat)) .filter(|s| s.affects().contains(&self.stat))
@ -141,19 +141,19 @@ impl CrypStat {
// applied with fold because it can be zeroed or multiplied // applied with fold because it can be zeroed or multiplied
// but still needs access to the base amount // but still needs access to the base amount
let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, cryp_colours, player_colours)); let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, construct_colours, player_colours));
self.value = value; self.value = value;
self.max = value; self.max = value;
self self
} }
pub fn reduce(&mut self, amt: u64) -> &mut CrypStat { pub fn reduce(&mut self, amt: u64) -> &mut ConstructStat {
self.value = self.value.saturating_sub(amt); self.value = self.value.saturating_sub(amt);
self self
} }
pub fn increase(&mut self, amt: u64) -> &mut CrypStat { pub fn increase(&mut self, amt: u64) -> &mut ConstructStat {
self.value = *[ self.value = *[
self.value.saturating_add(amt), self.value.saturating_add(amt),
self.max self.max
@ -162,7 +162,7 @@ impl CrypStat {
self self
} }
pub fn force(&mut self, v: u64) -> &mut CrypStat { pub fn force(&mut self, v: u64) -> &mut ConstructStat {
self.base = v; self.base = v;
self.value = v; self.value = v;
self.max = v; self.max = v;
@ -172,45 +172,45 @@ impl CrypStat {
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct CrypRecover { pub struct ConstructRecover {
pub id: Uuid, pub id: Uuid,
pub account: Uuid, pub account: Uuid,
pub name: String, pub name: String,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct Cryp { pub struct Construct {
pub id: Uuid, pub id: Uuid,
pub account: Uuid, pub account: Uuid,
pub red_damage: CrypStat, pub red_damage: ConstructStat,
pub red_life: CrypStat, pub red_life: ConstructStat,
pub blue_life: CrypStat, pub blue_life: ConstructStat,
pub blue_damage: CrypStat, pub blue_damage: ConstructStat,
pub green_damage: CrypStat, pub green_damage: ConstructStat,
pub speed: CrypStat, pub speed: ConstructStat,
pub green_life: CrypStat, pub green_life: ConstructStat,
pub evasion: CrypStat, pub evasion: ConstructStat,
pub skills: Vec<CrypSkill>, pub skills: Vec<ConstructSkill>,
pub effects: Vec<CrypEffect>, pub effects: Vec<ConstructEffect>,
pub specs: Vec<Spec>, pub specs: Vec<Spec>,
pub colours: Colours, pub colours: Colours,
pub name: String, pub name: String,
} }
impl Cryp { impl Construct {
pub fn new() -> Cryp { pub fn new() -> Construct {
let id = Uuid::new_v4(); let id = Uuid::new_v4();
return Cryp { return Construct {
id, id,
account: id, account: id,
red_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::RedDamage }, red_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::RedDamage },
red_life: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedLife }, red_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::RedLife },
blue_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::BlueDamage }, blue_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::BlueDamage },
blue_life: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueLife }, blue_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::BlueLife },
green_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::GreenDamage }, green_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::GreenDamage },
green_life: CrypStat { base: 1024, value: 1024, max: 1024, stat: Stat::GreenLife }, green_life: ConstructStat { base: 1024, value: 1024, max: 1024, stat: Stat::GreenLife },
speed: CrypStat { base: 128, value: 128, max: 128, stat: Stat::Speed }, speed: ConstructStat { base: 128, value: 128, max: 128, stat: Stat::Speed },
evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion }, evasion: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::Evasion },
skills: vec![], skills: vec![],
effects: vec![], effects: vec![],
specs: vec![], specs: vec![],
@ -219,28 +219,28 @@ impl Cryp {
}; };
} }
pub fn named(mut self, name: &String) -> Cryp { pub fn named(mut self, name: &String) -> Construct {
self.name = name.clone(); self.name = name.clone();
self self
} }
pub fn set_account(mut self, account: Uuid) -> Cryp { pub fn set_account(mut self, account: Uuid) -> Construct {
self.account = account; self.account = account;
self self
} }
pub fn learn(mut self, s: Skill) -> Cryp { pub fn learn(mut self, s: Skill) -> Construct {
self.skills.push(CrypSkill::new(s)); self.skills.push(ConstructSkill::new(s));
self.colours = Colours::from_cryp(&self); self.colours = Colours::from_construct(&self);
self self
} }
pub fn learn_mut(&mut self, s: Skill) -> &mut Cryp { pub fn learn_mut(&mut self, s: Skill) -> &mut Construct {
self.skills.push(CrypSkill::new(s)); self.skills.push(ConstructSkill::new(s));
self.calculate_colours() self.calculate_colours()
} }
pub fn forget(&mut self, skill: Skill) -> Result<&mut Cryp, Error> { pub fn forget(&mut self, skill: Skill) -> Result<&mut Construct, Error> {
match self.skills.iter().position(|s| s.skill == skill) { match self.skills.iter().position(|s| s.skill == skill) {
Some(i) => { Some(i) => {
self.skills.remove(i); self.skills.remove(i);
@ -250,7 +250,7 @@ impl Cryp {
} }
} }
pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Cryp, Error> { pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Construct, Error> {
if self.specs.len() >= 6 { if self.specs.len() >= 6 {
return Err(err_msg("maximum specs equipped")); return Err(err_msg("maximum specs equipped"));
} }
@ -259,7 +259,7 @@ impl Cryp {
return Ok(self.calculate_colours()); return Ok(self.calculate_colours());
} }
pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Cryp, Error> { pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Construct, Error> {
match self.specs.iter().position(|s| *s == spec) { match self.specs.iter().position(|s| *s == spec) {
Some(p) => self.specs.remove(p), Some(p) => self.specs.remove(p),
None => return Err(err_msg("spec not found")), None => return Err(err_msg("spec not found")),
@ -268,12 +268,12 @@ impl Cryp {
Ok(self.calculate_colours()) Ok(self.calculate_colours())
} }
fn calculate_colours(&mut self) -> &mut Cryp { fn calculate_colours(&mut self) -> &mut Construct {
self.colours = Colours::from_cryp(&self); self.colours = Colours::from_construct(&self);
self self
} }
pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Cryp { pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Construct {
self.specs.sort_unstable(); self.specs.sort_unstable();
self.red_damage.recalculate(&self.specs, &self.colours, player_colours); self.red_damage.recalculate(&self.specs, &self.colours, player_colours);
@ -292,7 +292,7 @@ impl Cryp {
self.green_life.value == 0 self.green_life.value == 0
} }
pub fn force_ko(&mut self) -> &mut Cryp { pub fn force_ko(&mut self) -> &mut Construct {
self.green_life.value = 0; self.green_life.value = 0;
self self
} }
@ -340,7 +340,7 @@ impl Cryp {
self.effects.iter().any(|s| s.effect == effect) self.effects.iter().any(|s| s.effect == effect)
} }
pub fn available_skills(&self) -> Vec<&CrypSkill> { pub fn available_skills(&self) -> Vec<&ConstructSkill> {
self.skills.iter() self.skills.iter()
.filter(|s| s.cd.is_none()) .filter(|s| s.cd.is_none())
.filter(|s| self.disabled(s.skill).is_none()) .filter(|s| self.disabled(s.skill).is_none())
@ -377,19 +377,19 @@ impl Cryp {
self.skills.iter().any(|s| s.skill == skill) self.skills.iter().any(|s| s.skill == skill)
} }
pub fn skill_on_cd(&self, skill: Skill) -> Option<&CrypSkill> { pub fn skill_on_cd(&self, skill: Skill) -> Option<&ConstructSkill> {
self.skills.iter().find(|s| s.skill == skill && s.cd.is_some()) self.skills.iter().find(|s| s.skill == skill && s.cd.is_some())
} }
pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Cryp { pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Construct {
let i = self.skills.iter().position(|s| s.skill == skill).unwrap(); let i = self.skills.iter().position(|s| s.skill == skill).unwrap();
self.skills.remove(i); self.skills.remove(i);
self.skills.push(CrypSkill::new(skill)); self.skills.push(ConstructSkill::new(skill));
self self
} }
pub fn reduce_cooldowns(&mut self) -> &mut Cryp { pub fn reduce_cooldowns(&mut self) -> &mut Construct {
for skill in self.skills.iter_mut() { for skill in self.skills.iter_mut() {
// if used cooldown // if used cooldown
if skill.skill.base_cd().is_some() { if skill.skill.base_cd().is_some() {
@ -412,7 +412,7 @@ impl Cryp {
self self
} }
pub fn reduce_effect_durations(&mut self) -> &mut Cryp { pub fn reduce_effect_durations(&mut self) -> &mut Construct {
self.effects = self.effects.clone().into_iter().filter_map(|mut effect| { self.effects = self.effects.clone().into_iter().filter_map(|mut effect| {
effect.duration = effect.duration.saturating_sub(1); effect.duration = effect.duration.saturating_sub(1);
@ -422,7 +422,7 @@ impl Cryp {
// info!("reduced effect {:?}", effect); // info!("reduced effect {:?}", effect);
return Some(effect); return Some(effect);
}).collect::<Vec<CrypEffect>>(); }).collect::<Vec<ConstructEffect>>();
self self
} }
@ -734,7 +734,7 @@ impl Cryp {
return events; return events;
} }
pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event { pub fn add_effect(&mut self, skill: Skill, effect: ConstructEffect) -> Event {
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
return Event::Immunity { return Event::Immunity {
skill, skill,
@ -776,10 +776,10 @@ impl Cryp {
} }
} }
pub fn cryp_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Cryp, Error> { pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Construct, Error> {
let query = " let query = "
SELECT data SELECT data
FROM cryps FROM constructs
WHERE id = $1 WHERE id = $1
AND account = $2; AND account = $2;
"; ";
@ -787,110 +787,110 @@ pub fn cryp_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Cryp
let result = tx let result = tx
.query(query, &[&id, &account_id])?; .query(query, &[&id, &account_id])?;
let result = result.iter().next().ok_or(format_err!("cryp {:} not found", id))?; let result = result.iter().next().ok_or(format_err!("construct {:} not found", id))?;
let cryp_bytes: Vec<u8> = result.get(0); let construct_bytes: Vec<u8> = result.get(0);
let cryp = from_slice::<Cryp>(&cryp_bytes).or_else(|_| cryp_recover(cryp_bytes, tx))?; let construct = from_slice::<Construct>(&construct_bytes).or_else(|_| construct_recover(construct_bytes, tx))?;
return Ok(cryp); return Ok(construct);
} }
pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> { pub fn construct_spawn(params: ConstructSpawnParams, tx: &mut Transaction, account: &Account) -> Result<Construct, Error> {
let cryp = Cryp::new() let construct = Construct::new()
.named(&params.name) .named(&params.name)
.set_account(account.id); .set_account(account.id);
let cryp_bytes = to_vec(&cryp)?; let construct_bytes = to_vec(&construct)?;
let query = " let query = "
INSERT INTO cryps (id, account, data) INSERT INTO constructs (id, account, data)
VALUES ($1, $2, $3) VALUES ($1, $2, $3)
RETURNING id, account; RETURNING id, account;
"; ";
let result = tx let result = tx
.query(query, &[&cryp.id, &account.id, &cryp_bytes])?; .query(query, &[&construct.id, &account.id, &construct_bytes])?;
let _returned = result.iter().next().ok_or(err_msg("no row returned"))?; let _returned = result.iter().next().ok_or(err_msg("no row returned"))?;
// info!("{:?} spawned cryp {:}", account.id, cryp.id); // info!("{:?} spawned construct {:}", account.id, construct.id);
return Ok(cryp); return Ok(construct);
} }
pub fn cryp_write(cryp: Cryp, tx: &mut Transaction) -> Result<Cryp, Error> { pub fn construct_write(construct: Construct, tx: &mut Transaction) -> Result<Construct, Error> {
let cryp_bytes = to_vec(&cryp)?; let construct_bytes = to_vec(&construct)?;
let query = " let query = "
UPDATE cryps UPDATE constructs
SET data = $1, updated_at = now() SET data = $1, updated_at = now()
WHERE id = $2 WHERE id = $2
RETURNING id, account, data; RETURNING id, account, data;
"; ";
let result = tx let result = tx
.query(query, &[&cryp_bytes, &cryp.id])?; .query(query, &[&construct_bytes, &construct.id])?;
let _returned = result.iter().next().expect("no row returned"); let _returned = result.iter().next().expect("no row returned");
// info!("{:?} wrote cryp", cryp.id); // info!("{:?} wrote construct", construct.id);
return Ok(cryp); return Ok(construct);
} }
pub fn cryp_recover(cryp_bytes: Vec<u8>, tx: &mut Transaction) -> Result<Cryp, Error> { pub fn construct_recover(construct_bytes: Vec<u8>, tx: &mut Transaction) -> Result<Construct, Error> {
let c = from_slice::<CrypRecover>(&cryp_bytes)?; let c = from_slice::<ConstructRecover>(&construct_bytes)?;
let mut cryp = Cryp::new() let mut construct = Construct::new()
.named(&c.name) .named(&c.name)
.set_account(c.account); .set_account(c.account);
cryp.id = c.id; construct.id = c.id;
info!("recovered cryp {:?}", c.name); info!("recovered construct {:?}", c.name);
return cryp_write(cryp, tx); return construct_write(construct, tx);
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use cryp::*; use construct::*;
use util::IntPct; use util::IntPct;
#[test] #[test]
fn create_cryp_test() { fn create_construct_test() {
let cryp = Cryp::new() let construct = Construct::new()
.named(&"hatchling".to_string()); .named(&"hatchling".to_string());
assert_eq!(cryp.name, "hatchling".to_string()); assert_eq!(construct.name, "hatchling".to_string());
return; return;
} }
#[test] #[test]
fn cryp_colours_test() { fn construct_colours_test() {
let mut cryp = Cryp::new() let mut construct = Construct::new()
.named(&"redboi".to_string()); .named(&"redboi".to_string());
cryp.learn_mut(Skill::Strike); construct.learn_mut(Skill::Strike);
cryp.spec_add(Spec::GreenLifeI).unwrap(); construct.spec_add(Spec::GreenLifeI).unwrap();
cryp.spec_add(Spec::RedDamageI).unwrap(); construct.spec_add(Spec::RedDamageI).unwrap();
cryp.spec_add(Spec::RedDamageI).unwrap(); construct.spec_add(Spec::RedDamageI).unwrap();
cryp.spec_add(Spec::BlueLifeI).unwrap(); construct.spec_add(Spec::BlueLifeI).unwrap();
assert_eq!(cryp.colours.red, 6); assert_eq!(construct.colours.red, 6);
assert_eq!(cryp.colours.green, 2); assert_eq!(construct.colours.green, 2);
assert_eq!(cryp.colours.blue, 2); assert_eq!(construct.colours.blue, 2);
return; return;
} }
#[test] #[test]
fn cryp_player_modifiers_test() { fn construct_player_modifiers_test() {
let mut cryp = Cryp::new() let mut construct = Construct::new()
.named(&"player player".to_string()); .named(&"player player".to_string());
cryp.spec_add(Spec::RedDamageI).unwrap(); construct.spec_add(Spec::RedDamageI).unwrap();
cryp.spec_add(Spec::GreenDamageI).unwrap(); construct.spec_add(Spec::GreenDamageI).unwrap();
cryp.spec_add(Spec::BlueDamageI).unwrap(); construct.spec_add(Spec::BlueDamageI).unwrap();
let player_colours = Colours { let player_colours = Colours {
red: 5, red: 5,
@ -898,11 +898,11 @@ mod tests {
blue: 25, blue: 25,
}; };
cryp.apply_modifiers(&player_colours); construct.apply_modifiers(&player_colours);
assert!(cryp.red_damage.value == cryp.red_damage.base + cryp.red_damage.base.pct(20)); assert!(construct.red_damage.value == construct.red_damage.base + construct.red_damage.base.pct(20));
assert!(cryp.green_damage.value == cryp.green_damage.base + cryp.green_damage.base.pct(40)); assert!(construct.green_damage.value == construct.green_damage.base + construct.green_damage.base.pct(40));
assert!(cryp.blue_damage.value == cryp.blue_damage.base + cryp.blue_damage.base.pct(80)); assert!(construct.blue_damage.value == construct.blue_damage.base + construct.blue_damage.base.pct(80));
return; return;
} }

View File

@ -13,7 +13,7 @@ use failure::err_msg;
use account::Account; use account::Account;
use rpc::{GameStateParams, GameSkillParams}; use rpc::{GameStateParams, GameSkillParams};
use cryp::{Cryp}; use construct::{Construct};
use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps}; use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps};
use player::{Player}; use player::{Player};
use instance::{instance_game_finished, global_game_finished}; use instance::{instance_game_finished, global_game_finished};
@ -29,7 +29,7 @@ pub enum Phase {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct Game { pub struct Game {
pub id: Uuid, pub id: Uuid,
pub player_cryps: usize, pub player_constructs: usize,
pub player_num: usize, pub player_num: usize,
pub players: Vec<Player>, pub players: Vec<Player>,
pub phase: Phase, pub phase: Phase,
@ -44,7 +44,7 @@ impl Game {
pub fn new() -> Game { pub fn new() -> Game {
return Game { return Game {
id: Uuid::new_v4(), id: Uuid::new_v4(),
player_cryps: 0, player_constructs: 0,
player_num: 0, player_num: 0,
players: vec![], players: vec![],
phase: Phase::Start, phase: Phase::Start,
@ -61,8 +61,8 @@ impl Game {
self self
} }
pub fn set_player_cryps(&mut self, size: usize) -> &mut Game { pub fn set_player_constructs(&mut self, size: usize) -> &mut Game {
self.player_cryps = size; self.player_constructs = size;
self self
} }
@ -84,12 +84,12 @@ impl Game {
return Err(err_msg("player already in game")); return Err(err_msg("player already in game"));
} }
if player.cryps.iter().all(|c| c.skills.len() == 0) { if player.constructs.iter().all(|c| c.skills.len() == 0) {
info!("WARNING: {:?} has no skills and has forfeited {:?}", player.name, self.id); info!("WARNING: {:?} has no skills and has forfeited {:?}", player.name, self.id);
player.forfeit(); player.forfeit();
} }
let player_description = player.cryps.iter().map(|c| c.name.clone()).collect::<Vec<String>>().join(", "); let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::<Vec<String>>().join(", ");
self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description)); self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description));
self.players.push(player); self.players.push(player);
@ -105,42 +105,42 @@ impl Game {
.ok_or(format_err!("{:?} not in game", id)) .ok_or(format_err!("{:?} not in game", id))
} }
pub fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> { pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> {
match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == id)) { match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == id)) {
Some(player) => player.cryps.iter_mut().find(|c| c.id == id), Some(player) => player.constructs.iter_mut().find(|c| c.id == id),
None => None, None => None,
} }
} }
pub fn cryp_by_id_take(&mut self, id: Uuid) -> Cryp { pub fn construct_by_id_take(&mut self, id: Uuid) -> Construct {
match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == id)) { match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == id)) {
Some(player) => { Some(player) => {
let i = player.cryps.iter().position(|c| c.id == id).unwrap(); let i = player.constructs.iter().position(|c| c.id == id).unwrap();
player.cryps.remove(i) player.constructs.remove(i)
} }
None => panic!("id not in game {:}", id), None => panic!("id not in game {:}", id),
} }
} }
fn all_cryps(&self) -> Vec<Cryp> { fn all_constructs(&self) -> Vec<Construct> {
self.players.clone() self.players.clone()
.into_iter() .into_iter()
.flat_map( .flat_map(
|t| t.cryps |t| t.constructs
.into_iter()) .into_iter())
.collect::<Vec<Cryp>>() .collect::<Vec<Construct>>()
} }
pub fn update_cryp(&mut self, cryp: &mut Cryp) -> &mut Game { pub fn update_construct(&mut self, construct: &mut Construct) -> &mut Game {
match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == cryp.id)) { match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == construct.id)) {
Some(player) => { Some(player) => {
let index = player.cryps.iter().position(|t| t.id == cryp.id).unwrap(); let index = player.constructs.iter().position(|t| t.id == construct.id).unwrap();
player.cryps.remove(index); player.constructs.remove(index);
player.cryps.push(cryp.clone()); player.constructs.push(construct.clone());
player.cryps.sort_unstable_by_key(|c| c.id); player.constructs.sort_unstable_by_key(|c| c.id);
}, },
None => panic!("cryp not in game"), None => panic!("construct not in game"),
}; };
self self
@ -148,7 +148,7 @@ impl Game {
pub fn can_start(&self) -> bool { pub fn can_start(&self) -> bool {
return self.players.len() == self.player_num return self.players.len() == self.player_num
&& self.players.iter().all(|t| t.cryps.len() == self.player_cryps) && self.players.iter().all(|t| t.constructs.len() == self.player_constructs)
} }
pub fn start(mut self) -> Game { pub fn start(mut self) -> Game {
@ -198,7 +198,7 @@ impl Game {
.filter(|t| t.bot) { .filter(|t| t.bot) {
let player_player = self.players.iter().find(|t| t.id != mobs.id).unwrap(); let player_player = self.players.iter().find(|t| t.id != mobs.id).unwrap();
for mob in mobs.cryps.iter() { for mob in mobs.constructs.iter() {
let skill = mob.mob_select_skill(); let skill = mob.mob_select_skill();
// info!("{:?} {:?}", mob.name, skill); // info!("{:?} {:?}", mob.name, skill);
match skill { match skill {
@ -209,8 +209,8 @@ impl Game {
// more than once // more than once
let mut find_target = || { let mut find_target = || {
match s.defensive() { match s.defensive() {
true => &mobs.cryps[rng.gen_range(0, mobs.cryps.len())], true => &mobs.constructs[rng.gen_range(0, mobs.constructs.len())],
false => &player_player.cryps[rng.gen_range(0, player_player.cryps.len())], false => &player_player.constructs[rng.gen_range(0, player_player.constructs.len())],
} }
}; };
@ -231,7 +231,7 @@ impl Game {
match self.add_skill(player_id, mob_id, target_id, s) { match self.add_skill(player_id, mob_id, target_id, s) {
Ok(_) => (), Ok(_) => (),
Err(e) => { Err(e) => {
info!("{:?}", self.cryp_by_id(mob_id)); info!("{:?}", self.construct_by_id(mob_id));
panic!("{:?} unable to add pve mob skill {:?}", e, s); panic!("{:?} unable to add pve mob skill {:?}", e, s);
}, },
} }
@ -242,7 +242,7 @@ impl Game {
self self
} }
fn add_skill(&mut self, player_id: Uuid, source_cryp_id: Uuid, target_cryp_id: Option<Uuid>, skill: Skill) -> Result<&mut Game, Error> { fn add_skill(&mut self, player_id: Uuid, source_construct_id: Uuid, target_construct_id: Option<Uuid>, skill: Skill) -> Result<&mut Game, Error> {
// check player in game // check player in game
self.player_by_id(player_id)?; self.player_by_id(player_id)?;
@ -251,8 +251,8 @@ impl Game {
} }
let final_target_id = match skill.self_targeting() { let final_target_id = match skill.self_targeting() {
true => source_cryp_id, true => source_construct_id,
false => match target_cryp_id { false => match target_construct_id {
Some(t) => t, Some(t) => t,
None => return Err(err_msg("skill requires a target")), None => return Err(err_msg("skill requires a target")),
} }
@ -260,49 +260,49 @@ impl Game {
// target checks // target checks
{ {
let target = match self.cryp_by_id(final_target_id) { let target = match self.construct_by_id(final_target_id) {
Some(c) => c, Some(c) => c,
None => return Err(err_msg("target cryp not in game")), None => return Err(err_msg("target construct not in game")),
}; };
// fixme for rez // fixme for rez
if target.is_ko() { if target.is_ko() {
return Err(err_msg("target cryp is ko")); return Err(err_msg("target construct is ko"));
} }
} }
// cryp checks // construct checks
{ {
let cryp = match self.cryp_by_id(source_cryp_id) { let construct = match self.construct_by_id(source_construct_id) {
Some(c) => c, Some(c) => c,
None => return Err(err_msg("cryp not in game")), None => return Err(err_msg("construct not in game")),
}; };
if cryp.is_ko() { if construct.is_ko() {
return Err(err_msg("cryp is ko")); return Err(err_msg("construct is ko"));
} }
// check the cryp has the skill // check the construct has the skill
if !cryp.knows(skill) { if !construct.knows(skill) {
return Err(err_msg("cryp does not have that skill")); return Err(err_msg("construct does not have that skill"));
} }
if cryp.skill_on_cd(skill).is_some() { if construct.skill_on_cd(skill).is_some() {
return Err(err_msg("abiltity on cooldown")); return Err(err_msg("abiltity on cooldown"));
} }
// check here as well so uncastable spells don't go on the stack // check here as well so uncastable spells don't go on the stack
if let Some(disable) = cryp.disabled(skill) { if let Some(disable) = construct.disabled(skill) {
return Err(format_err!("skill disabled {:?}", disable)); return Err(format_err!("skill disabled {:?}", disable));
} }
} }
// replace cryp skill // replace construct skill
if let Some(s) = self.stack.iter_mut().position(|s| s.source_cryp_id == source_cryp_id) { if let Some(s) = self.stack.iter_mut().position(|s| s.source_construct_id == source_construct_id) {
self.stack.remove(s); self.stack.remove(s);
} }
let skill = Cast::new(source_cryp_id, player_id, final_target_id, skill); let skill = Cast::new(source_construct_id, player_id, final_target_id, skill);
self.stack.push(skill); self.stack.push(skill);
return Ok(self); return Ok(self);
@ -349,7 +349,7 @@ impl Game {
let mut sorted = self.stack.clone(); let mut sorted = self.stack.clone();
sorted.iter_mut() sorted.iter_mut()
.for_each(|s| { .for_each(|s| {
let caster = self.cryp_by_id(s.source_cryp_id).unwrap(); let caster = self.construct_by_id(s.source_construct_id).unwrap();
let speed = caster.skill_speed(s.skill); let speed = caster.skill_speed(s.skill);
s.speed = speed; s.speed = speed;
}); });
@ -361,19 +361,19 @@ impl Game {
self self
} }
fn cryp_aoe_targets(&self, cryp_id: Uuid) -> Vec<Uuid> { fn construct_aoe_targets(&self, construct_id: Uuid) -> Vec<Uuid> {
self.players.iter() self.players.iter()
.find(|t| t.cryps.iter().any(|c| c.id == cryp_id)) .find(|t| t.constructs.iter().any(|c| c.id == construct_id))
.unwrap() .unwrap()
.cryps .constructs
.iter() .iter()
.map(|c| c.id) .map(|c| c.id)
.collect() .collect()
} }
pub fn get_targets(&self, skill: Skill, source: &Cryp, target_cryp_id: Uuid) -> Vec<Uuid> { pub fn get_targets(&self, skill: Skill, source: &Construct, target_construct_id: Uuid) -> Vec<Uuid> {
let target_player = self.players.iter() let target_player = self.players.iter()
.find(|t| t.cryps.iter().any(|c| c.id == target_cryp_id)) .find(|t| t.constructs.iter().any(|c| c.id == target_construct_id))
.unwrap(); .unwrap();
if let Some(t) = target_player.taunting() { if let Some(t) = target_player.taunting() {
@ -381,8 +381,8 @@ impl Game {
} }
match source.skill_is_aoe(skill) { match source.skill_is_aoe(skill) {
true => self.cryp_aoe_targets(target_cryp_id), true => self.construct_aoe_targets(target_construct_id),
false => vec![target_cryp_id], false => vec![target_construct_id],
} }
} }
@ -392,7 +392,7 @@ impl Game {
} }
// find their statuses with ticks // find their statuses with ticks
let mut ticks = self.all_cryps() let mut ticks = self.all_constructs()
.iter() .iter()
.flat_map( .flat_map(
|c| c.effects |c| c.effects
@ -442,30 +442,30 @@ impl Game {
} }
fn progress_durations(&mut self, resolved: &Vec<Cast>) -> &mut Game { fn progress_durations(&mut self, resolved: &Vec<Cast>) -> &mut Game {
for mut cryp in self.all_cryps() { for mut construct in self.all_constructs() {
// info!("progressing durations for {:}", cryp.name); // info!("progressing durations for {:}", construct.name);
if cryp.is_ko() { if construct.is_ko() {
continue; continue;
} }
// only reduce cooldowns if no cd was used // only reduce cooldowns if no cd was used
// have to borrow self for the skill check // have to borrow self for the skill check
{ {
if let Some(skill) = resolved.iter().find(|s| s.source_cryp_id == cryp.id) { if let Some(skill) = resolved.iter().find(|s| s.source_construct_id == construct.id) {
if skill.used_cooldown() { if skill.used_cooldown() {
cryp.skill_set_cd(skill.skill); construct.skill_set_cd(skill.skill);
} else { } else {
cryp.reduce_cooldowns(); construct.reduce_cooldowns();
} }
} else { } else {
cryp.reduce_cooldowns(); construct.reduce_cooldowns();
} }
} }
// always reduce durations // always reduce durations
cryp.reduce_effect_durations(); construct.reduce_effect_durations();
self.update_cryp(&mut cryp); self.update_construct(&mut construct);
} }
self self
@ -536,11 +536,11 @@ impl Game {
} }
pub fn finished(&self) -> bool { pub fn finished(&self) -> bool {
self.players.iter().any(|t| t.cryps.iter().all(|c| c.is_ko())) self.players.iter().any(|t| t.constructs.iter().all(|c| c.is_ko()))
} }
pub fn winner(&self) -> Option<&Player> { pub fn winner(&self) -> Option<&Player> {
self.players.iter().find(|t| t.cryps.iter().any(|c| !c.is_ko())) self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko()))
} }
fn finish(mut self) -> Game { fn finish(mut self) -> Game {
@ -548,7 +548,7 @@ impl Game {
self.log.push(format!("Game finished.")); self.log.push(format!("Game finished."));
{ {
let winner = self.players.iter().find(|t| t.cryps.iter().any(|c| !c.is_ko())); let winner = self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko()));
match winner { match winner {
Some(w) => self.log.push(format!("Winner: {:}", w.name)), Some(w) => self.log.push(format!("Winner: {:}", w.name)),
None => self.log.push(format!("Game was drawn.")), None => self.log.push(format!("Game was drawn.")),
@ -630,7 +630,7 @@ pub fn game_get(tx: &mut Transaction, id: Uuid) -> Result<Game, Error> {
None => return Err(err_msg("game not found")), None => return Err(err_msg("game not found")),
}; };
// tells from_slice to cast into a cryp // tells from_slice to cast into a construct
let game_bytes: Vec<u8> = returned.get("data"); let game_bytes: Vec<u8> = returned.get("data");
let game = from_slice::<Game>(&game_bytes)?; let game = from_slice::<Game>(&game_bytes)?;
@ -700,7 +700,7 @@ pub fn game_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
// game // game
// .set_player_num(2) // .set_player_num(2)
// .set_player_cryps(3) // .set_player_constructs(3)
// .set_mode(GameMode::Pvp); // .set_mode(GameMode::Pvp);
// game_write(tx, &game)?; // game_write(tx, &game)?;
@ -761,7 +761,7 @@ pub fn game_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
// None => return Err(err_msg("game not found")), // None => return Err(err_msg("game not found")),
// }; // };
// // tells from_slice to cast into a cryp // // tells from_slice to cast into a construct
// let game_bytes: Vec<u8> = returned.get("data"); // let game_bytes: Vec<u8> = returned.get("data");
// let game = match from_slice::<Game>(&game_bytes) { // let game = match from_slice::<Game>(&game_bytes) {
// Ok(g) => g, // Ok(g) => g,
@ -805,7 +805,7 @@ pub fn game_update(tx: &mut Transaction, game: &Game) -> Result<(), Error> {
pub fn game_skill(params: GameSkillParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> { pub fn game_skill(params: GameSkillParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
let mut game = game_get(tx, params.game_id)?; let mut game = game_get(tx, params.game_id)?;
game.add_skill(account.id, params.cryp_id, params.target_cryp_id, params.skill)?; game.add_skill(account.id, params.construct_id, params.target_construct_id, params.skill)?;
if game.skill_phase_finished() { if game.skill_phase_finished() {
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -830,17 +830,17 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou
Ok(game) Ok(game)
} }
// pub fn game_pve_new(cryp_ids: Vec<Uuid>, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result<Game, Error> { // pub fn game_pve_new(construct_ids: Vec<Uuid>, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
// if cryp_ids.len() == 0 { // if construct_ids.len() == 0 {
// return Err(err_msg("no cryps selected")); // return Err(err_msg("no constructs selected"));
// } // }
// let cryps = cryp_ids // let constructs = construct_ids
// .iter() // .iter()
// .map(|id| cryp_get(tx, *id, account.id)) // .map(|id| construct_get(tx, *id, account.id))
// .collect::<Result<Vec<Cryp>, Error>>()?; // .collect::<Result<Vec<Construct>, Error>>()?;
// if cryps.len() > 3 { // if constructs.len() > 3 {
// return Err(err_msg("player size too large (3 max)")); // return Err(err_msg("player size too large (3 max)"));
// } // }
@ -850,16 +850,16 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou
// game; // game;
// .set_player_num(2) // .set_player_num(2)
// .set_player_cryps(cryps.len()) // .set_player_constructs(constructs.len())
// .set_mode(mode); // .set_mode(mode);
// // create the mob player // // create the mob player
// let mob_player = generate_mob_player(mode, &cryps); // let mob_player = generate_mob_player(mode, &constructs);
// // add the players // // add the players
// let mut plr_player = Player::new(account.id); // let mut plr_player = Player::new(account.id);
// plr_player // plr_player
// .set_cryps(cryps); // .set_constructs(constructs);
// game // game
@ -872,7 +872,7 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou
// } // }
// pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> { // pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
// let game = game_pve_new(params.cryp_ids, GameMode::Normal, tx, account)?; // let game = game_pve_new(params.construct_ids, GameMode::Normal, tx, account)?;
// // persist // // persist
// game_write(tx, &game)?; // game_write(tx, &game)?;
@ -887,7 +887,7 @@ pub fn game_instance_new(tx: &mut Transaction, players: Vec<Player>, game_id: Uu
game game
.set_player_num(2) .set_player_num(2)
.set_player_cryps(3) .set_player_constructs(3)
.set_instance(instance_id); .set_instance(instance_id);
// create the initiators player // create the initiators player
@ -924,11 +924,11 @@ pub fn game_instance_new(tx: &mut Transaction, players: Vec<Player>, game_id: Uu
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use game::*; use game::*;
use cryp::*; use construct::*;
use util::IntPct; use util::IntPct;
fn create_test_game() -> Game { fn create_test_game() -> Game {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"pronounced \"creeep\"".to_string()) .named(&"pronounced \"creeep\"".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestStun) .learn(Skill::TestStun)
@ -940,7 +940,7 @@ mod tests {
.learn(Skill::Stun) .learn(Skill::Stun)
.learn(Skill::Block); .learn(Skill::Block);
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"lemongrass tea".to_string()) .named(&"lemongrass tea".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestStun) .learn(Skill::TestStun)
@ -956,7 +956,7 @@ mod tests {
game game
.set_player_num(2) .set_player_num(2)
.set_player_cryps(1); .set_player_constructs(1);
let x_player_id = Uuid::new_v4(); let x_player_id = Uuid::new_v4();
x.account = x_player_id; x.account = x_player_id;
@ -976,22 +976,22 @@ mod tests {
} }
fn create_2v2_test_game() -> Game { fn create_2v2_test_game() -> Game {
let mut i = Cryp::new() let mut i = Construct::new()
.named(&"pretaliate".to_string()) .named(&"pretaliate".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::TestTouch);
let mut j = Cryp::new() let mut j = Construct::new()
.named(&"poy sian".to_string()) .named(&"poy sian".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::TestTouch);
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"pronounced \"creeep\"".to_string()) .named(&"pronounced \"creeep\"".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::TestTouch);
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"lemongrass tea".to_string()) .named(&"lemongrass tea".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::TestTouch);
@ -1000,7 +1000,7 @@ mod tests {
game game
.set_player_num(2) .set_player_num(2)
.set_player_cryps(2); .set_player_constructs(2);
let i_player_id = Uuid::new_v4(); let i_player_id = Uuid::new_v4();
i.account = i_player_id; i.account = i_player_id;
@ -1028,11 +1028,11 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Attack).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Attack).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1053,11 +1053,11 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestStun).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1068,7 +1068,7 @@ mod tests {
// should auto progress back to skill phase // should auto progress back to skill phase
assert!(game.phase == Phase::Skill); assert!(game.phase == Phase::Skill);
// assert!(game.player_by_id(y_player.id).cryps[0].is_stunned()); // assert!(game.player_by_id(y_player.id).constructs[0].is_stunned());
// assert!(game.player_by_id(y_player.id).skills_required() == 0); // assert!(game.player_by_id(y_player.id).skills_required() == 0);
} }
@ -1079,18 +1079,18 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().red_damage.force(1000000000); game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().red_damage.force(1000000000);
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().speed.force(1000000000); game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().speed.force(1000000000);
// just in case // just in case
// remove all mitigation // remove all mitigation
game.player_by_id(x_player.id).unwrap().cryp_by_id(x_cryp.id).unwrap().red_life.force(0); game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0);
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestStun).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1098,7 +1098,7 @@ mod tests {
assert!(game.skill_phase_finished()); assert!(game.skill_phase_finished());
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(!game.player_by_id(y_player.id).unwrap().cryps[0].is_stunned()); assert!(!game.player_by_id(y_player.id).unwrap().constructs[0].is_stunned());
assert!(game.phase == Phase::Finish); assert!(game.phase == Phase::Finish);
} }
@ -1109,18 +1109,18 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
// should auto progress back to skill phase // should auto progress back to skill phase
assert!(game.phase == Phase::Skill); assert!(game.phase == Phase::Skill);
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some()); assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some());
assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestTouch).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1129,20 +1129,20 @@ mod tests {
// should auto progress back to skill phase // should auto progress back to skill phase
assert!(game.phase == Phase::Skill); assert!(game.phase == Phase::Skill);
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some()); assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some());
// second round // second round
// now we block and it should go back on cd // now we block and it should go back on cd
// game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Stun).unwrap(); // game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_none()); assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_none());
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
} }
#[test] #[test]
@ -1152,11 +1152,11 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.add_skill(x_player.id, x_cryp.id, None, Skill::TestParry).unwrap(); game.add_skill(x_player.id, x_construct.id, None, Skill::TestParry).unwrap();
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestStun).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestStun).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1164,9 +1164,9 @@ mod tests {
game = game.resolve_phase_start(); game = game.resolve_phase_start();
// should not be stunned because of parry // should not be stunned because of parry
assert!(game.player_by_id(x_player.id).unwrap().cryps[0].is_stunned() == false); assert!(game.player_by_id(x_player.id).unwrap().constructs[0].is_stunned() == false);
// riposte // riposte
assert_eq!(game.player_by_id(y_player.id).unwrap().cryps[0].green_life(), (1024 - x_cryp.red_damage().pct(Skill::Riposte.multiplier()))); assert_eq!(game.player_by_id(y_player.id).unwrap().constructs[0].green_life(), (1024 - x_construct.red_damage().pct(Skill::Riposte.multiplier())));
} }
#[test] #[test]
@ -1176,29 +1176,29 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Corrupt); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Corrupt);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Corrupt).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Corrupt).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
// apply buff // apply buff
game.add_skill(x_player.id, x_cryp.id, None, Skill::Corrupt).unwrap(); game.add_skill(x_player.id, x_construct.id, None, Skill::Corrupt).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Corrupt)); assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Corrupt));
// attack and receive debuff // attack and receive debuff
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Corruption)); assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Corruption));
} }
#[test] #[test]
@ -1208,21 +1208,21 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Scatter); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Scatter);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Scatter).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Scatter).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
// apply buff // apply buff
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Scatter).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Scatter).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Scatter)); assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Scatter));
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap(); let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
match event { match event {
@ -1237,13 +1237,13 @@ mod tests {
} }
// attack and receive scatter hit // attack and receive scatter hit
game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
let Resolution { source: _, target, event } = game.resolved.pop().unwrap(); let Resolution { source: _, target, event } = game.resolved.pop().unwrap();
assert_eq!(target.id, y_cryp.id); assert_eq!(target.id, y_construct.id);
match event { match event {
Event::Damage { amount, skill: _, mitigation: _, colour: _} => Event::Damage { amount, skill: _, mitigation: _, colour: _} =>
assert_eq!(amount, 256.pct(Skill::Attack.multiplier()) >> 1), assert_eq!(amount, 256.pct(Skill::Attack.multiplier()) >> 1),
@ -1258,30 +1258,30 @@ mod tests {
// let x_player = game.players[0].clone(); // let x_player = game.players[0].clone();
// let y_player = game.players[1].clone(); // let y_player = game.players[1].clone();
// let x_cryp = x_player.cryps[0].clone(); // let x_construct = x_player.constructs[0].clone();
// let y_cryp = y_player.cryps[0].clone(); // let y_construct = y_player.constructs[0].clone();
// game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Hostility); // game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Hostility);
// while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Hostility).is_some() { // while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Hostility).is_some() {
// game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); // game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
// } // }
// // apply buff // // apply buff
// game.add_skill(x_player.id, x_cryp.id, Some(x_cryp.id), Skill::Hostility).unwrap(); // game.add_skill(x_player.id, x_construct.id, Some(x_construct.id), Skill::Hostility).unwrap();
// game.player_ready(x_player.id).unwrap(); // game.player_ready(x_player.id).unwrap();
// game.player_ready(y_player.id).unwrap(); // game.player_ready(y_player.id).unwrap();
// game = game.resolve_phase_start(); // game = game.resolve_phase_start();
// assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Hostility)); // assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Hostility));
// // attack and receive debuff // // attack and receive debuff
// game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestAttack).unwrap(); // game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestAttack).unwrap();
// game.player_ready(x_player.id).unwrap(); // game.player_ready(x_player.id).unwrap();
// game.player_ready(y_player.id).unwrap(); // game.player_ready(y_player.id).unwrap();
// game = game.resolve_phase_start(); // game = game.resolve_phase_start();
// info!("{:#?}", game); // info!("{:#?}", game);
// assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Hatred)); // assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Hatred));
// } // }
#[test] #[test]
@ -1291,21 +1291,21 @@ mod tests {
let i_player = game.players[0].clone(); let i_player = game.players[0].clone();
let x_player = game.players[1].clone(); let x_player = game.players[1].clone();
let i_cryp = i_player.cryps[0].clone(); let i_construct = i_player.constructs[0].clone();
let j_cryp = i_player.cryps[1].clone(); let j_construct = i_player.constructs[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = x_player.cryps[1].clone(); let y_construct = x_player.constructs[1].clone();
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Ruin); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Ruin);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Ruin).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Ruin).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::Ruin).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Ruin).unwrap();
game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1316,7 +1316,7 @@ mod tests {
.into_iter() .into_iter()
.filter(|r| { .filter(|r| {
let Resolution { source, target: _, event } = r; let Resolution { source, target: _, event } = r;
match source.id == x_cryp.id { match source.id == x_construct.id {
true => match event { true => match event {
Event::Effect { effect, duration, skill: _ } => { Event::Effect { effect, duration, skill: _ } => {
assert!(*effect == Effect::Stun); assert!(*effect == Effect::Stun);
@ -1341,21 +1341,21 @@ mod tests {
let i_player = game.players[0].clone(); let i_player = game.players[0].clone();
let x_player = game.players[1].clone(); let x_player = game.players[1].clone();
let i_cryp = i_player.cryps[0].clone(); let i_construct = i_player.constructs[0].clone();
let j_cryp = i_player.cryps[1].clone(); let j_construct = i_player.constructs[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = x_player.cryps[1].clone(); let y_construct = x_player.constructs[1].clone();
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Taunt); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Taunt);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Taunt).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Taunt).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::Taunt).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Taunt).unwrap();
game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1365,8 +1365,8 @@ mod tests {
assert!(game.resolved.len() == 5); assert!(game.resolved.len() == 5);
while let Some(r) = game.resolved.pop() { while let Some(r) = game.resolved.pop() {
let Resolution { source , target, event: _ } = r; let Resolution { source , target, event: _ } = r;
if [i_cryp.id, j_cryp.id].contains(&source.id) { if [i_construct.id, j_construct.id].contains(&source.id) {
assert!(target.id == x_cryp.id); assert!(target.id == x_construct.id);
} }
} }
} }
@ -1378,15 +1378,15 @@ mod tests {
let i_player = game.players[0].clone(); let i_player = game.players[0].clone();
let x_player = game.players[1].clone(); let x_player = game.players[1].clone();
let i_cryp = i_player.cryps[0].clone(); let i_construct = i_player.constructs[0].clone();
let j_cryp = i_player.cryps[1].clone(); let j_construct = i_player.constructs[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = x_player.cryps[1].clone(); let y_construct = x_player.constructs[1].clone();
game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1396,17 +1396,17 @@ mod tests {
assert!([Phase::Skill, Phase::Finish].contains(&game.phase)); assert!([Phase::Skill, Phase::Finish].contains(&game.phase));
// kill a cryp // kill a construct
game.player_by_id(i_player.id).unwrap().cryp_by_id(i_cryp.id).unwrap().green_life.reduce(u64::max_value()); game.player_by_id(i_player.id).unwrap().construct_by_id(i_construct.id).unwrap().green_life.reduce(u64::max_value());
assert!(game.player_by_id(i_player.id).unwrap().skills_required() == 1); assert!(game.player_by_id(i_player.id).unwrap().skills_required() == 1);
assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2); assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2);
// add some more skills // add some more skills
game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, x_cryp.id, Some(j_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap();
game.add_skill(x_player.id, y_cryp.id, Some(j_cryp.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap();
assert!(game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::TestTouch).is_err()); assert!(game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).is_err());
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1426,33 +1426,33 @@ mod tests {
let x_player = game.players[0].clone(); let x_player = game.players[0].clone();
let y_player = game.players[1].clone(); let y_player = game.players[1].clone();
let x_cryp = x_player.cryps[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_cryp = y_player.cryps[0].clone(); let y_construct = y_player.constructs[0].clone();
// make the purify cryp super fast so it beats out decay // make the purify construct super fast so it beats out decay
game.cryp_by_id(y_cryp.id).unwrap().speed.force(10000000); game.construct_by_id(y_construct.id).unwrap().speed.force(10000000);
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Decay); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Decay);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Decay).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Decay).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Siphon); game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Siphon);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Siphon).is_some() { while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Siphon).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.cryp_by_id(y_cryp.id).unwrap().learn_mut(Skill::Purify); game.construct_by_id(y_construct.id).unwrap().learn_mut(Skill::Purify);
while game.cryp_by_id(y_cryp.id).unwrap().skill_on_cd(Skill::Purify).is_some() { while game.construct_by_id(y_construct.id).unwrap().skill_on_cd(Skill::Purify).is_some() {
game.cryp_by_id(y_cryp.id).unwrap().reduce_cooldowns(); game.construct_by_id(y_construct.id).unwrap().reduce_cooldowns();
} }
// apply buff // apply buff
game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Decay).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Decay).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Decay)); assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Decay));
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap(); let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
match event { match event {
@ -1463,7 +1463,7 @@ mod tests {
game.resolved.clear(); game.resolved.clear();
// remove // remove
game.add_skill(y_player.id, y_cryp.id, Some(y_cryp.id), Skill::Purify).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1476,14 +1476,14 @@ mod tests {
} }
}; };
game.add_skill(y_player.id, x_cryp.id, Some(y_cryp.id), Skill::Siphon).unwrap(); game.add_skill(y_player.id, x_construct.id, Some(y_construct.id), Skill::Siphon).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
game.resolved.clear(); game.resolved.clear();
game.add_skill(y_player.id, y_cryp.id, Some(y_cryp.id), Skill::Purify).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();

View File

@ -16,7 +16,7 @@ use chrono::Duration;
use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, InstanceStateParams}; use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, InstanceStateParams};
use account::Account; use account::Account;
use player::{Player, player_create, player_get, player_global_update}; use player::{Player, player_create, player_get, player_global_update};
use cryp::{Cryp, cryp_get}; use construct::{Construct, construct_get};
use mob::{instance_mobs}; use mob::{instance_mobs};
use game::{Game, Phase, game_get, game_write}; use game::{Game, Phase, game_get, game_write};
use item::{Item}; use item::{Item};
@ -144,8 +144,8 @@ impl Instance {
self.open = false; self.open = false;
self.players = iter::repeat_with(|| { self.players = iter::repeat_with(|| {
let bot_id = Uuid::new_v4(); let bot_id = Uuid::new_v4();
let cryps = instance_mobs(bot_id); let constructs = instance_mobs(bot_id);
let mut p = Player::new(bot_id, &name(), cryps).set_bot(true); let mut p = Player::new(bot_id, &name(), constructs).set_bot(true);
p.set_ready(true); p.set_ready(true);
p p
}) })
@ -202,8 +202,8 @@ impl Instance {
self.players[i].set_ready(v); self.players[i].set_ready(v);
// start the game even if afk noobs have no skills // start the game even if afk noobs have no skills
if !self.phase_timed_out() && self.players[i].cryps.iter().all(|c| c.skills.len() == 0) { if !self.phase_timed_out() && self.players[i].constructs.iter().all(|c| c.skills.len() == 0) {
return Err(err_msg("your cryps have no skills")); return Err(err_msg("your constructs have no skills"));
} }
// create a game object if both players are ready // create a game object if both players are ready
@ -247,7 +247,7 @@ impl Instance {
game game
.set_player_num(2) .set_player_num(2)
.set_player_cryps(3) .set_player_constructs(3)
.set_instance(self.id); .set_instance(self.id);
// create the initiators player // create the initiators player
@ -472,17 +472,17 @@ impl Instance {
Ok(self) Ok(self)
} }
pub fn vbox_apply(mut self, account: Uuid, index: usize, cryp_id: Uuid) -> Result<Instance, Error> { pub fn vbox_apply(mut self, account: Uuid, index: usize, construct_id: Uuid) -> Result<Instance, Error> {
self.vbox_action_allowed(account)?; self.vbox_action_allowed(account)?;
self.account_player(account)? self.account_player(account)?
.vbox_apply(index, cryp_id)?; .vbox_apply(index, construct_id)?;
Ok(self) Ok(self)
} }
pub fn vbox_unequip(mut self, account: Uuid, target: Item, cryp_id: Uuid) -> Result<Instance, Error> { pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid) -> Result<Instance, Error> {
self.vbox_action_allowed(account)?; self.vbox_action_allowed(account)?;
self.account_player(account)? self.account_player(account)?
.vbox_unequip(target, cryp_id)?; .vbox_unequip(target, construct_id)?;
Ok(self) Ok(self)
} }
} }
@ -627,7 +627,7 @@ pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account:
}; };
instance = instance_create(tx, instance)?; instance = instance_create(tx, instance)?;
let join_params = InstanceJoinParams { instance_id: instance.id, cryp_ids: params.cryp_ids }; let join_params = InstanceJoinParams { instance_id: instance.id, construct_ids: params.construct_ids };
instance_join(join_params, tx, account) instance_join(join_params, tx, account)
} }
@ -635,16 +635,16 @@ pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account:
pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> { pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
let mut instance = instance_get(tx, params.instance_id)?; let mut instance = instance_get(tx, params.instance_id)?;
let cryps = params.cryp_ids let constructs = params.construct_ids
.iter() .iter()
.map(|id| cryp_get(tx, *id, account.id)) .map(|id| construct_get(tx, *id, account.id))
.collect::<Result<Vec<Cryp>, Error>>()?; .collect::<Result<Vec<Construct>, Error>>()?;
if cryps.len() != 3 { if constructs.len() != 3 {
return Err(format_err!("incorrect player size. ({:})", 3)); return Err(format_err!("incorrect player size. ({:})", 3));
} }
let player = player_create(tx, Player::new(account.id, &account.name, cryps), instance.id, account)?; let player = player_create(tx, Player::new(account.id, &account.name, constructs), instance.id, account)?;
instance.add_player(player)?; instance.add_player(player)?;
@ -736,8 +736,8 @@ mod tests {
.add_bots(); .add_bots();
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); let player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true);
let player_id = player.id; let player_id = player.id;
instance.add_player(player).expect("could not add player"); instance.add_player(player).expect("could not add player");
@ -754,8 +754,8 @@ mod tests {
fn instance_bot_vbox_test() { fn instance_bot_vbox_test() {
let instance = Instance::new(); let instance = Instance::new();
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let _player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); let _player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true);
} }
#[test] #[test]
@ -767,16 +767,16 @@ mod tests {
assert_eq!(instance.max_players, 2); assert_eq!(instance.max_players, 2);
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let player = Player::new(player_account, &"a".to_string(), cryps); let player = Player::new(player_account, &"a".to_string(), constructs);
let a_id = player.id; let a_id = player.id;
instance.add_player(player).expect("could not add player"); instance.add_player(player).expect("could not add player");
assert!(!instance.can_start()); assert!(!instance.can_start());
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let player = Player::new(player_account, &"b".to_string(), cryps); let player = Player::new(player_account, &"b".to_string(), constructs);
let b_id = player.id; let b_id = player.id;
instance.add_player(player).expect("could not add player"); instance.add_player(player).expect("could not add player");
@ -806,16 +806,16 @@ mod tests {
.expect("could not create instance"); .expect("could not create instance");
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let player = Player::new(player_account, &"a".to_string(), cryps); let player = Player::new(player_account, &"a".to_string(), constructs);
let a_id = player.id; let a_id = player.id;
instance.add_player(player).expect("could not add player"); instance.add_player(player).expect("could not add player");
assert!(!instance.can_start()); assert!(!instance.can_start());
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let player = Player::new(player_account, &"b".to_string(), cryps); let player = Player::new(player_account, &"b".to_string(), constructs);
let b_id = player.id; let b_id = player.id;
instance.add_player(player).expect("could not add player"); instance.add_player(player).expect("could not add player");

View File

@ -1,6 +1,6 @@
use skill::{Skill, Effect, Colour}; use skill::{Skill, Effect, Colour};
use spec::{Spec}; use spec::{Spec};
use cryp::{Colours}; use construct::{Colours};
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
pub enum Item { pub enum Item {
@ -277,46 +277,46 @@ impl Item {
100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()), 100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()),
Item::Stun => format!("Stun target cryp for {:?}T", Item::Stun => format!("Stun target construct for {:?}T",
self.into_skill().unwrap().effect().first().unwrap().get_duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Buff => format!("Increase target cryp red damage and speed by {:?}%", Item::Buff => format!("Increase target construct red damage and speed by {:?}%",
self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100), self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100),
Item::Debuff => format!("Slow target cryp speed by {:?}%", Item::Debuff => format!("Slow target construct speed by {:?}%",
100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()), 100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()),
// specs // specs
// Base // Base
Item::Damage => format!("Base ITEM for increased DAMAGE. DAMAGE determines the power of your SKILLS."), Item::Damage => format!("Base ITEM for increased DAMAGE. DAMAGE determines the power of your SKILLS."),
Item::Life => format!("Base ITEM for increased LIFE. Item::Life => format!("Base ITEM for increased LIFE.
When your CRYP reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."),
Item::Speed => format!("Base ITEM for increased SPEED. Item::Speed => format!("Base ITEM for increased SPEED.
SPEED determines the order in which skills resolve."), SPEED determines the order in which skills resolve."),
// Lifes Upgrades // Lifes Upgrades
Item::GreenLifeI => format!("Increases CRYP GreenLife. Item::GreenLifeI => format!("Increases CONSTRUCT GreenLife.
When your CRYP reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."),
Item::RedLifeI => format!("Increases CRYP RedLife. Item::RedLifeI => format!("Increases CONSTRUCT RedLife.
Red damage dealt to your cryp reduces RedLife before GreenLife."), Red damage dealt to your construct reduces RedLife before GreenLife."),
Item::BlueLifeI => format!("Increases CRYP BlueLife. Item::BlueLifeI => format!("Increases CONSTRUCT BlueLife.
Blue damage dealt to your cryp reduces BlueLife before GreenLife."), Blue damage dealt to your construct reduces BlueLife before GreenLife."),
Item::GRLI => format!("Increases CRYP GreenLife + RedLife"), Item::GRLI => format!("Increases CONSTRUCT GreenLife + RedLife"),
Item::GBLI => format!("Increases CRYP GreenLife + BlueLife"), Item::GBLI => format!("Increases CONSTRUCT GreenLife + BlueLife"),
Item::RBLI => format!("Increases CRYP RedLife + BlueLife"), Item::RBLI => format!("Increases CONSTRUCT RedLife + BlueLife"),
// Damage Upgrades // Damage Upgrades
Item::RedDamageI => format!("Increases CRYP RedDamage."), Item::RedDamageI => format!("Increases CONSTRUCT RedDamage."),
Item::BlueDamageI => format!("Increases CRYP BlueDamage."), Item::BlueDamageI => format!("Increases CONSTRUCT BlueDamage."),
Item::GreenDamageI => format!("Increases CRYP GreenDamage."), Item::GreenDamageI => format!("Increases CONSTRUCT GreenDamage."),
Item::GRDI => format!("Increases CRYP GreenDamage + RedDamage."), Item::GRDI => format!("Increases CONSTRUCT GreenDamage + RedDamage."),
Item::GBDI => format!("Increases CRYP GreenDamage + BlueDamage."), Item::GBDI => format!("Increases CONSTRUCT GreenDamage + BlueDamage."),
Item::RBDI => format!("Increases CRYP RedDamage + BlueDamage."), Item::RBDI => format!("Increases CONSTRUCT RedDamage + BlueDamage."),
// Speed Upgrades // Speed Upgrades
Item::RedSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::RedSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::BlueSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::BlueSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GreenSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::GreenSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GRSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::GRSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GBSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::GBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::RBSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), Item::RBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
// Skills <- need to move effect mulltipliers into skills // Skills <- need to move effect mulltipliers into skills
Item::Amplify => format!("Increase red and blue power by {:?}%. Lasts {:?}T", Item::Amplify => format!("Increase red and blue power by {:?}%. Lasts {:?}T",
@ -324,7 +324,7 @@ impl Item {
self.into_skill().unwrap().effect().first().unwrap().get_duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Banish => format!("Banish target for {:?}T. Item::Banish => format!("Banish target for {:?}T.
Banished cryps are immune to all skills and effects.", Banished constructs are immune to all skills and effects.",
self.into_skill().unwrap().effect().first().unwrap().get_duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Blast => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()), Item::Blast => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()),
@ -333,7 +333,7 @@ impl Item {
"Hits twice for red and blue damage. Damage is random 0 to 30% + {:?}% red and blue power.", "Hits twice for red and blue damage. Damage is random 0 to 30% + {:?}% red and blue power.",
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Clutch => format!("Cryp cannot be KO'd while active. Item::Clutch => format!("Construct cannot be KO'd while active.
Additionally provides immunity to disables."), Additionally provides immunity to disables."),
Item::Corrupt => format!( Item::Corrupt => format!(
@ -389,10 +389,10 @@ impl Item {
"Self targetting skill. Recharges RedLife for", "Self targetting skill. Recharges RedLife for",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
"If a red skill is parried the cryp will riposte the source dealing red damage", "If a red skill is parried the construct will riposte the source dealing red damage",
Skill::Riposte.multiplier()), Skill::Riposte.multiplier()),
Item::Purge => format!("Remove buffs from target cryp"), Item::Purge => format!("Remove buffs from target construct"),
Item::Purify => format!( Item::Purify => format!(
"Remove debuffs and heals for {:?}% green power per debuff removed.", "Remove debuffs and heals for {:?}% green power per debuff removed.",
@ -406,11 +406,11 @@ impl Item {
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Ruin => format!( Item::Ruin => format!(
"Team wide Stun for {:?}T. Stunned cryps are unable to cast skills.", "Team wide Stun for {:?}T. Stunned constructs are unable to cast skills.",
self.into_skill().unwrap().effect().first().unwrap().get_duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Scatter => format!( Item::Scatter => format!(
"Caster links with target. Linked cryps split incoming damage evenly. Recharges target blue shield {:?}% of blue power", "Caster links with target. Linked constructs split incoming damage evenly. Recharges target blue shield {:?}% of blue power",
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Silence => format!( Item::Silence => format!(

View File

@ -1,7 +1,7 @@
extern crate rand; extern crate rand;
extern crate uuid; extern crate uuid;
extern crate tungstenite; extern crate tungstenite;
extern crate bcrypt; extern crate bconstructt;
extern crate chrono; extern crate chrono;
extern crate dotenv; extern crate dotenv;
@ -18,7 +18,7 @@ extern crate fern;
#[macro_use] extern crate log; #[macro_use] extern crate log;
mod account; mod account;
mod cryp; mod construct;
mod game; mod game;
mod instance; mod instance;
mod item; mod item;
@ -51,7 +51,7 @@ fn setup_logger() -> Result<(), fern::InitError> {
.level_for("tungstenite", log::LevelFilter::Info) .level_for("tungstenite", log::LevelFilter::Info)
.level(log::LevelFilter::Debug) .level(log::LevelFilter::Debug)
.chain(std::io::stdout()) .chain(std::io::stdout())
.chain(fern::log_file("log/cryps.log")?) .chain(fern::log_file("log/constructs.log")?)
.apply()?; .apply()?;
Ok(()) Ok(())
} }

View File

@ -4,10 +4,10 @@ use rand::prelude::*;
use rand::distributions::Alphanumeric; use rand::distributions::Alphanumeric;
use std::iter; use std::iter;
use cryp::{Cryp}; use construct::{Construct};
use skill::{Skill}; use skill::{Skill};
pub fn generate_mob() -> Cryp { pub fn generate_mob() -> Construct {
let mut rng = thread_rng(); let mut rng = thread_rng();
let name: String = iter::repeat(()) let name: String = iter::repeat(())
@ -15,86 +15,86 @@ pub fn generate_mob() -> Cryp {
.take(8) .take(8)
.collect(); .collect();
let mob = Cryp::new() let mob = Construct::new()
.named(&name); .named(&name);
return mob; return mob;
} }
// fn quick_game(player_size: usize) -> Vec<Cryp> { // fn quick_game(player_size: usize) -> Vec<Construct> {
// iter::repeat_with(|| // iter::repeat_with(||
// generate_mob() // generate_mob()
// .set_account(Uuid::nil()) // .set_account(Uuid::nil())
// .learn(Skill::Attack)) // .learn(Skill::Attack))
// .take(player_size) // .take(player_size)
// .collect::<Vec<Cryp>>() // .collect::<Vec<Construct>>()
// } // }
pub fn instance_mobs(player_id: Uuid) -> Vec<Cryp> { pub fn instance_mobs(player_id: Uuid) -> Vec<Construct> {
iter::repeat_with(|| iter::repeat_with(||
generate_mob() generate_mob()
.set_account(player_id)) .set_account(player_id))
// .learn(Skill::Attack)) // .learn(Skill::Attack))
.take(3) .take(3)
.collect::<Vec<Cryp>>() .collect::<Vec<Construct>>()
} }
// fn zone_3v2_attack(player_lvl: u8) -> Vec<Cryp> { // fn zone_3v2_attack(player_lvl: u8) -> Vec<Construct> {
// let x = Cryp::new() // let x = Construct::new()
// .named(&"hench".to_string()) // .named(&"hench".to_string())
// .learn(Skill::Attack); // .learn(Skill::Attack);
// let y = Cryp::new() // let y = Construct::new()
// .named(&"bench".to_string()) // .named(&"bench".to_string())
// .learn(Skill::Attack); // .learn(Skill::Attack);
// return vec![x, y]; // return vec![x, y];
// } // }
// fn zone_2v2_caster(player_lvl: u8) -> Vec<Cryp> { // fn zone_2v2_caster(player_lvl: u8) -> Vec<Construct> {
// let x = Cryp::new() // let x = Construct::new()
// .named(&"robe".to_string()) // .named(&"robe".to_string())
// .learn(Skill::Blast); // .learn(Skill::Blast);
// let y = Cryp::new() // let y = Construct::new()
// .named(&"wizard hat".to_string()) // .named(&"wizard hat".to_string())
// .learn(Skill::Blast); // .learn(Skill::Blast);
// return vec![x, y]; // return vec![x, y];
// } // }
// fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec<Cryp> { // fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec<Construct> {
// let x = Cryp::new() // let x = Construct::new()
// .named(&"jungle juice".to_string()) // .named(&"jungle juice".to_string())
// .learn(Skill::Attack); // .learn(Skill::Attack);
// let y = Cryp::new() // let y = Construct::new()
// .named(&"bamboo basher".to_string()) // .named(&"bamboo basher".to_string())
// .learn(Skill::Attack) // .learn(Skill::Attack)
// .learn(Skill::Stun); // .learn(Skill::Stun);
// let z = Cryp::new() // let z = Construct::new()
// .named(&"lemongrass tea".to_string()) // .named(&"lemongrass tea".to_string())
// .learn(Skill::Attack); // .learn(Skill::Attack);
// return vec![x, y, z]; // return vec![x, y, z];
// } // }
// fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Cryp> { // fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Construct> {
// let x = Cryp::new() // let x = Construct::new()
// .named(&"coinage".to_string()) // .named(&"coinage".to_string())
// .learn(Skill::Attack) // .learn(Skill::Attack)
// .learn(Skill::Parry) // .learn(Skill::Parry)
// .learn(Skill::Block); // .learn(Skill::Block);
// let y = Cryp::new() // let y = Construct::new()
// .named(&"wololo".to_string()) // .named(&"wololo".to_string())
// // big strong // // big strong
// // .learn(Skill::Blast) // // .learn(Skill::Blast)
// .learn(Skill::Heal) // .learn(Skill::Heal)
// .learn(Skill::Triage); // .learn(Skill::Triage);
// let z = Cryp::new() // let z = Construct::new()
// .named(&"quarry".to_string()) // .named(&"quarry".to_string())
// .learn(Skill::Attack) // .learn(Skill::Attack)
// .learn(Skill::Parry) // .learn(Skill::Parry)
@ -104,22 +104,22 @@ pub fn instance_mobs(player_id: Uuid) -> Vec<Cryp> {
// } // }
// pub fn generate_mob_player(mode: GameMode, cryps: &Vec<Cryp>) -> Player { // pub fn generate_mob_player(mode: GameMode, constructs: &Vec<Construct>) -> Player {
// let mut mob_player = Player::new(Uuid::nil()); // let mut mob_player = Player::new(Uuid::nil());
// let cryp_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl; // let construct_lvl = constructs.iter().max_by_key(|c| c.lvl).unwrap().lvl;
// let player_size = cryps.len(); // let player_size = constructs.len();
// let mobs = match mode { // let mobs = match mode {
// GameMode::Normal => quick_game(cryp_lvl, player_size), // GameMode::Normal => quick_game(construct_lvl, player_size),
// GameMode::Zone3v2Attack => zone_3v2_attack(cryp_lvl), // GameMode::Zone3v2Attack => zone_3v2_attack(construct_lvl),
// GameMode::Zone2v2Caster => zone_2v2_caster(cryp_lvl), // GameMode::Zone2v2Caster => zone_2v2_caster(construct_lvl),
// GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(cryp_lvl), // GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(construct_lvl),
// GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(cryp_lvl), // GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(construct_lvl),
// _ => panic!("{:?} not handled for pve mobs", mode), // _ => panic!("{:?} not handled for pve mobs", mode),
// }; // };
// mob_player.set_cryps(mobs); // mob_player.set_constructs(mobs);
// return mob_player; // return mob_player;

View File

@ -9,10 +9,10 @@ use failure::Error;
use failure::err_msg; use failure::err_msg;
use account::Account; use account::Account;
use cryp::{Cryp, Colours, cryp_get}; use construct::{Construct, Colours, construct_get};
use vbox::{Vbox}; use vbox::{Vbox};
use item::{Item, ItemEffect}; use item::{Item, ItemEffect};
use rpc::{PlayerCrypsSetParams}; use rpc::{PlayerConstructsSetParams};
use instance::{Instance}; use instance::{Instance};
use skill::{Effect}; use skill::{Effect};
@ -30,20 +30,20 @@ pub struct Player {
pub name: String, pub name: String,
pub vbox: Vbox, pub vbox: Vbox,
pub score: Score, pub score: Score,
pub cryps: Vec<Cryp>, pub constructs: Vec<Construct>,
pub bot: bool, pub bot: bool,
pub ready: bool, pub ready: bool,
pub warnings: u8, pub warnings: u8,
} }
impl Player { impl Player {
pub fn new(account: Uuid, name: &String, cryps: Vec<Cryp>) -> Player { pub fn new(account: Uuid, name: &String, constructs: Vec<Construct>) -> Player {
Player { Player {
id: account, id: account,
name: name.clone(), name: name.clone(),
vbox: Vbox::new(), vbox: Vbox::new(),
score: Score { wins: 0, losses: 0 }, score: Score { wins: 0, losses: 0 },
cryps, constructs,
bot: false, bot: false,
ready: false, ready: false,
warnings: 0, warnings: 0,
@ -66,8 +66,8 @@ impl Player {
} }
pub fn forfeit(&mut self) -> &mut Player { pub fn forfeit(&mut self) -> &mut Player {
for cryp in self.cryps.iter_mut() { for construct in self.constructs.iter_mut() {
cryp.force_ko(); construct.force_ko();
} }
self self
} }
@ -84,19 +84,19 @@ impl Player {
self self
} }
pub fn cryp_get(&mut self, id: Uuid) -> Result<&mut Cryp, Error> { pub fn construct_get(&mut self, id: Uuid) -> Result<&mut Construct, Error> {
self.cryps.iter_mut().find(|c| c.id == id).ok_or(err_msg("cryp not found")) self.constructs.iter_mut().find(|c| c.id == id).ok_or(err_msg("construct not found"))
} }
pub fn autobuy(&mut self) -> &mut Player { pub fn autobuy(&mut self) -> &mut Player {
let mut rng = thread_rng(); let mut rng = thread_rng();
// first check if any cryps have no skills // first check if any constructs have no skills
// if there is one find an item in vbox that gives a skill // if there is one find an item in vbox that gives a skill
while let Some(c) = self.cryps.iter().position(|c| c.skills.len() == 0) { while let Some(c) = self.constructs.iter().position(|c| c.skills.len() == 0) {
if let Some(s) = self.vbox.bound.iter().position(|v| v.into_skill().is_some()) { if let Some(s) = self.vbox.bound.iter().position(|v| v.into_skill().is_some()) {
let cryp_id = self.cryps[c].id; let construct_id = self.constructs[c].id;
self.vbox_apply(s, cryp_id).expect("could not apply"); self.vbox_apply(s, construct_id).expect("could not apply");
continue; continue;
} }
info!("no skills available..."); info!("no skills available...");
@ -106,23 +106,23 @@ impl Player {
// inb4 montecarlo gan // inb4 montecarlo gan
loop { loop {
let (target_cryp_i, target_cryp_id) = match self.cryps.iter().any(|c| c.skills.len() < 3) { let (target_construct_i, target_construct_id) = match self.constructs.iter().any(|c| c.skills.len() < 3) {
true => { true => {
let mut target_cryp_i = 0; let mut target_construct_i = 0;
for (j, c) in self.cryps.iter().enumerate() { for (j, c) in self.constructs.iter().enumerate() {
if c.skills.len() < self.cryps[target_cryp_i].skills.len() { if c.skills.len() < self.constructs[target_construct_i].skills.len() {
target_cryp_i = j; target_construct_i = j;
} }
} }
(target_cryp_i, self.cryps[target_cryp_i].id) (target_construct_i, self.constructs[target_construct_i].id)
}, },
false => { false => {
let i = rng.gen_range(0, 3); let i = rng.gen_range(0, 3);
(i, self.cryps[i].id) (i, self.constructs[i].id)
}, },
}; };
let needs_skills = self.cryps[target_cryp_i].skills.len() < 3; let needs_skills = self.constructs[target_construct_i].skills.len() < 3;
let group_i = match needs_skills { let group_i = match needs_skills {
true => 1, true => 1,
false => 2, false => 2,
@ -161,7 +161,7 @@ impl Player {
// first 2 colours can be whatever // first 2 colours can be whatever
self.vbox_combine(vec![0, 1, combo_i]).ok(); self.vbox_combine(vec![0, 1, combo_i]).ok();
let item_i = self.vbox.bound.len() - 1; let item_i = self.vbox.bound.len() - 1;
self.vbox_apply(item_i, target_cryp_id).ok(); self.vbox_apply(item_i, target_construct_id).ok();
} }
return self; return self;
@ -188,7 +188,7 @@ impl Player {
Ok(self) Ok(self)
} }
pub fn vbox_apply(&mut self, index: usize, cryp_id: Uuid) -> Result<&mut Player, Error> { pub fn vbox_apply(&mut self, index: usize, construct_id: Uuid) -> Result<&mut Player, Error> {
if self.vbox.bound.get(index).is_none() { if self.vbox.bound.get(index).is_none() {
return Err(format_err!("no item at index {:?}", index)); return Err(format_err!("no item at index {:?}", index));
} }
@ -198,31 +198,31 @@ impl Player {
match item.effect() { match item.effect() {
Some(ItemEffect::Skill) => { Some(ItemEffect::Skill) => {
let skill = item.into_skill().ok_or(format_err!("item {:?} has no associated skill", item))?; let skill = item.into_skill().ok_or(format_err!("item {:?} has no associated skill", item))?;
let cryp = self.cryp_get(cryp_id)?; let construct = self.construct_get(construct_id)?;
// done here because i teach them a tonne of skills for tests // done here because i teach them a tonne of skills for tests
let max_skills = 3; let max_skills = 3;
if cryp.skills.len() >= max_skills { if construct.skills.len() >= max_skills {
return Err(format_err!("cryp at max skills ({:?})", max_skills)); return Err(format_err!("construct at max skills ({:?})", max_skills));
} }
if cryp.knows(skill) { if construct.knows(skill) {
return Err(format_err!("cryp already knows skill ({:?})" , skill)); return Err(format_err!("construct already knows skill ({:?})" , skill));
} }
cryp.learn_mut(skill); construct.learn_mut(skill);
}, },
Some(ItemEffect::Spec) => { Some(ItemEffect::Spec) => {
let spec = item.into_spec().ok_or(format_err!("item {:?} has no associated spec", item))?; let spec = item.into_spec().ok_or(format_err!("item {:?} has no associated spec", item))?;
let cryp = self.cryp_get(cryp_id)?; let construct = self.construct_get(construct_id)?;
cryp.spec_add(spec)?; construct.spec_add(spec)?;
}, },
None => return Err(err_msg("item has no effect on cryps")), None => return Err(err_msg("item has no effect on constructs")),
} }
// now the item has been applied // now the item has been applied
// recalculate the stats of the whole player // recalculate the stats of the whole player
let player_colours = self.cryps.iter().fold(Colours::new(), |tc, c| { let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| {
Colours { Colours {
red: tc.red + c.colours.red, red: tc.red + c.colours.red,
green: tc.green + c.colours.green, green: tc.green + c.colours.green,
@ -230,14 +230,14 @@ impl Player {
} }
}); });
for cryp in self.cryps.iter_mut() { for construct in self.constructs.iter_mut() {
cryp.apply_modifiers(&player_colours); construct.apply_modifiers(&player_colours);
} }
Ok(self) Ok(self)
} }
pub fn vbox_unequip(&mut self, target: Item, cryp_id: Uuid) -> Result<&mut Player, Error> { pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid) -> Result<&mut Player, Error> {
if self.vbox.bound.len() >= 9 { if self.vbox.bound.len() >= 9 {
return Err(err_msg("too many items bound")); return Err(err_msg("too many items bound"));
} }
@ -245,20 +245,20 @@ impl Player {
match target.effect() { match target.effect() {
Some(ItemEffect::Skill) => { Some(ItemEffect::Skill) => {
let skill = target.into_skill().ok_or(format_err!("item {:?} has no associated skill", target))?; let skill = target.into_skill().ok_or(format_err!("item {:?} has no associated skill", target))?;
let cryp = self.cryp_get(cryp_id)?; let construct = self.construct_get(construct_id)?;
cryp.forget(skill)?; construct.forget(skill)?;
}, },
Some(ItemEffect::Spec) => { Some(ItemEffect::Spec) => {
let spec = target.into_spec().ok_or(format_err!("item {:?} has no associated spec", target))?; let spec = target.into_spec().ok_or(format_err!("item {:?} has no associated spec", target))?;
let cryp = self.cryp_get(cryp_id)?; let construct = self.construct_get(construct_id)?;
cryp.spec_remove(spec)?; construct.spec_remove(spec)?;
}, },
None => return Err(err_msg("item has no effect on cryps")), None => return Err(err_msg("item has no effect on constructs")),
} }
// now the item has been applied // now the item has been applied
// recalculate the stats of the whole player // recalculate the stats of the whole player
let player_colours = self.cryps.iter().fold(Colours::new(), |tc, c| { let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| {
Colours { Colours {
red: tc.red + c.colours.red, red: tc.red + c.colours.red,
green: tc.green + c.colours.green, green: tc.green + c.colours.green,
@ -266,8 +266,8 @@ impl Player {
} }
}); });
for cryp in self.cryps.iter_mut() { for construct in self.constructs.iter_mut() {
cryp.apply_modifiers(&player_colours); construct.apply_modifiers(&player_colours);
} }
self.vbox.bound.push(target); self.vbox.bound.push(target);
@ -278,27 +278,27 @@ impl Player {
// GAME METHODS // GAME METHODS
pub fn skills_required(&self) -> usize { pub fn skills_required(&self) -> usize {
let required = self.cryps.iter() let required = self.constructs.iter()
.filter(|c| !c.is_ko()) .filter(|c| !c.is_ko())
.filter(|c| c.available_skills().len() > 0) .filter(|c| c.available_skills().len() > 0)
.collect::<Vec<&Cryp>>().len(); .collect::<Vec<&Construct>>().len();
// info!("{:} requires {:} skills this turn", self.id, required); // info!("{:} requires {:} skills this turn", self.id, required);
return required; return required;
} }
pub fn taunting(&self) -> Option<&Cryp> { pub fn taunting(&self) -> Option<&Construct> {
self.cryps.iter() self.constructs.iter()
.find(|c| c.affected(Effect::Taunt)) .find(|c| c.affected(Effect::Taunt))
} }
pub fn set_cryps(&mut self, mut cryps: Vec<Cryp>) -> &mut Player { pub fn set_constructs(&mut self, mut constructs: Vec<Construct>) -> &mut Player {
cryps.sort_unstable_by_key(|c| c.id); constructs.sort_unstable_by_key(|c| c.id);
self.cryps = cryps; self.constructs = constructs;
self self
} }
pub fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> { pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> {
self.cryps.iter_mut().find(|c| c.id == id) self.constructs.iter_mut().find(|c| c.id == id)
} }
} }
@ -320,7 +320,7 @@ pub fn player_get(tx: &mut Transaction, account_id: Uuid, instance_id: Uuid) ->
None => return Err(err_msg("player not found")), None => return Err(err_msg("player not found")),
}; };
// tells from_slice to cast into a cryp // tells from_slice to cast into a construct
let bytes: Vec<u8> = returned.get("data"); let bytes: Vec<u8> = returned.get("data");
let data = from_slice::<Player>(&bytes)?; let data = from_slice::<Player>(&bytes)?;
@ -386,24 +386,24 @@ pub fn player_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
return Ok(()); return Ok(());
} }
pub fn player_mm_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> { pub fn player_mm_constructs_set(params: PlayerConstructsSetParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
if params.cryp_ids.len() != 3 { if params.construct_ids.len() != 3 {
return Err(err_msg("player size is 3")); return Err(err_msg("player size is 3"));
} }
let cryps = params.cryp_ids let constructs = params.construct_ids
.iter() .iter()
.map(|id| cryp_get(tx, *id, account.id)) .map(|id| construct_get(tx, *id, account.id))
.collect::<Result<Vec<Cryp>, Error>>()?; .collect::<Result<Vec<Construct>, Error>>()?;
let player = match player_get(tx, account.id, Uuid::nil()) { let player = match player_get(tx, account.id, Uuid::nil()) {
Ok(mut p) => { Ok(mut p) => {
p.cryps = cryps; p.constructs = constructs;
p.vbox = Vbox::new(); p.vbox = Vbox::new();
player_global_update(tx, p, false)? player_global_update(tx, p, false)?
}, },
Err(_) => { Err(_) => {
player_create(tx, Player::new(account.id, &account.name, cryps), Uuid::nil(), &account)? player_create(tx, Player::new(account.id, &account.name, constructs), Uuid::nil(), &account)?
} }
}; };
@ -419,12 +419,12 @@ mod tests {
#[test] #[test]
fn player_bot_vbox_test() { fn player_bot_vbox_test() {
let player_account = Uuid::new_v4(); let player_account = Uuid::new_v4();
let cryps = instance_mobs(player_account); let constructs = instance_mobs(player_account);
let mut player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); let mut player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true);
player.vbox.fill(); player.vbox.fill();
player.autobuy(); player.autobuy();
assert!(player.cryps.iter().all(|c| c.skills.len() >= 1)); assert!(player.constructs.iter().all(|c| c.skills.len() >= 1));
} }
} }

View File

@ -16,12 +16,12 @@ use failure::Error;
use failure::err_msg; use failure::err_msg;
use net::Db; use net::Db;
use cryp::{Cryp, cryp_spawn}; use construct::{Construct, construct_spawn};
use game::{Game, game_state, game_skill, game_ready}; use game::{Game, game_state, game_skill, game_ready};
use account::{Account, account_create, account_login, account_from_token, account_cryps, account_instances}; use account::{Account, account_create, account_login, account_from_token, account_constructs, account_instances};
use skill::{Skill}; use skill::{Skill};
use spec::{Spec}; use spec::{Spec};
use player::{Score, player_mm_cryps_set}; use player::{Score, player_mm_constructs_set};
use instance::{Instance, instance_state, instance_new, instance_ready, instance_join}; use instance::{Instance, instance_state, instance_new, instance_ready, instance_join};
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip}; use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
use item::{Item, ItemInfoCtr, item_info}; use item::{Item, ItemInfoCtr, item_info};
@ -71,11 +71,11 @@ impl Rpc {
"account_login" => Rpc::account_login(data, &mut tx, client), "account_login" => Rpc::account_login(data, &mut tx, client),
// auth methods // auth methods
"account_cryps" => Rpc::account_cryps(data, &mut tx, account.unwrap(), client), "account_constructs" => Rpc::account_constructs(data, &mut tx, account.unwrap(), client),
"account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client), "account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client),
// "account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client), // "account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client),
"cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client), "construct_spawn" => Rpc::construct_spawn(data, &mut tx, account.unwrap(), client),
"game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client), "game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client),
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client), "game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
@ -86,7 +86,7 @@ impl Rpc {
"instance_new" => Rpc::instance_new(data, &mut tx, account.unwrap(), client), "instance_new" => Rpc::instance_new(data, &mut tx, account.unwrap(), client),
"instance_state" => Rpc::instance_state(data, &mut tx, account.unwrap(), client), "instance_state" => Rpc::instance_state(data, &mut tx, account.unwrap(), client),
"player_mm_cryps_set" => Rpc::player_mm_cryps_set(data, &mut tx, account.unwrap(), client), "player_mm_constructs_set" => Rpc::player_mm_constructs_set(data, &mut tx, account.unwrap(), client),
"player_vbox_accept" => Rpc::player_vbox_accept(data, &mut tx, account.unwrap(), client), "player_vbox_accept" => Rpc::player_vbox_accept(data, &mut tx, account.unwrap(), client),
"player_vbox_apply" => Rpc::player_vbox_apply(data, &mut tx, account.unwrap(), client), "player_vbox_apply" => Rpc::player_vbox_apply(data, &mut tx, account.unwrap(), client),
"player_vbox_combine" => Rpc::player_vbox_combine(data, &mut tx, account.unwrap(), client), "player_vbox_combine" => Rpc::player_vbox_combine(data, &mut tx, account.unwrap(), client),
@ -165,20 +165,20 @@ impl Rpc {
} }
fn cryp_spawn(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> { fn construct_spawn(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
let msg = from_slice::<CrypSpawnMsg>(&data).or(Err(err_msg("invalid params")))?; let msg = from_slice::<ConstructSpawnMsg>(&data).or(Err(err_msg("invalid params")))?;
Rpc::send_msg(client, RpcResponse { Rpc::send_msg(client, RpcResponse {
method: "cryp_spawn".to_string(), method: "construct_spawn".to_string(),
params: RpcResult::CrypSpawn(cryp_spawn(msg.params, tx, &account)?) params: RpcResult::ConstructSpawn(construct_spawn(msg.params, tx, &account)?)
})?; })?;
let cryp_list = RpcResponse { let construct_list = RpcResponse {
method: "account_cryps".to_string(), method: "account_constructs".to_string(),
params: RpcResult::CrypList(account_cryps(tx, &account)?) params: RpcResult::ConstructList(account_constructs(tx, &account)?)
}; };
Ok(cryp_list) Ok(construct_list)
} }
fn account_create(data: Vec<u8>, tx: &mut Transaction, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> { fn account_create(data: Vec<u8>, tx: &mut Transaction, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
@ -210,13 +210,13 @@ impl Rpc {
// let account = account_create(AccountCreateParams { name: acc_name, password: "grepgrepgrep".to_string() }, tx)?; // let account = account_create(AccountCreateParams { name: acc_name, password: "grepgrepgrep".to_string() }, tx)?;
// let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();
// cryp_spawn(CrypSpawnParams { name }, tx, &account)?; // construct_spawn(ConstructSpawnParams { name }, tx, &account)?;
// let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();
// cryp_spawn(CrypSpawnParams { name }, tx, &account)?; // construct_spawn(ConstructSpawnParams { name }, tx, &account)?;
// let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();
// cryp_spawn(CrypSpawnParams { name }, tx, &account)?; // construct_spawn(ConstructSpawnParams { name }, tx, &account)?;
// let res = RpcResponse { // let res = RpcResponse {
// method: "account_create".to_string(), // method: "account_create".to_string(),
@ -227,10 +227,10 @@ impl Rpc {
// } // }
fn account_cryps(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> { fn account_constructs(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
Ok(RpcResponse { Ok(RpcResponse {
method: "account_cryps".to_string(), method: "account_constructs".to_string(),
params: RpcResult::CrypList(account_cryps(tx, &account)?) params: RpcResult::ConstructList(account_constructs(tx, &account)?)
}) })
} }
@ -300,12 +300,12 @@ impl Rpc {
} }
} }
fn player_mm_cryps_set(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> { fn player_mm_constructs_set(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
let msg = from_slice::<PlayerCrypsSetMsg>(&data).or(Err(err_msg("invalid params")))?; let msg = from_slice::<PlayerConstructsSetMsg>(&data).or(Err(err_msg("invalid params")))?;
let response = RpcResponse { let response = RpcResponse {
method: "instance_state".to_string(), method: "instance_state".to_string(),
params: RpcResult::InstanceState(player_mm_cryps_set(msg.params, tx, &account)?) params: RpcResult::InstanceState(player_mm_constructs_set(msg.params, tx, &account)?)
}; };
return Ok(response); return Ok(response);
@ -354,8 +354,8 @@ impl Rpc {
}; };
Rpc::send_msg(client, RpcResponse { Rpc::send_msg(client, RpcResponse {
method: "account_cryps".to_string(), method: "account_constructs".to_string(),
params: RpcResult::CrypList(account_cryps(tx, &account)?) params: RpcResult::ConstructList(account_constructs(tx, &account)?)
})?; })?;
return Ok(response); return Ok(response);
@ -381,8 +381,8 @@ impl Rpc {
}; };
Rpc::send_msg(client, RpcResponse { Rpc::send_msg(client, RpcResponse {
method: "account_cryps".to_string(), method: "account_constructs".to_string(),
params: RpcResult::CrypList(account_cryps(tx, &account)?) params: RpcResult::ConstructList(account_constructs(tx, &account)?)
})?; })?;
return Ok(response); return Ok(response);
@ -397,12 +397,12 @@ pub struct RpcResponse {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub enum RpcResult { pub enum RpcResult {
CrypSpawn(Cryp), ConstructSpawn(Construct),
CrypForget(Cryp), ConstructForget(Construct),
CrypLearn(Cryp), ConstructLearn(Construct),
CrypUnspec(Cryp), ConstructUnspec(Construct),
Account(Account), Account(Account),
CrypList(Vec<Cryp>), ConstructList(Vec<Construct>),
GameState(Game), GameState(Game),
ItemInfo(ItemInfoCtr), ItemInfo(ItemInfoCtr),
InstanceScores(Vec<(String, Score)>), InstanceScores(Vec<(String, Score)>),
@ -422,50 +422,50 @@ pub struct RpcMessage {
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct CrypSpawnMsg { struct ConstructSpawnMsg {
method: String, method: String,
params: CrypSpawnParams, params: ConstructSpawnParams,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct CrypSpawnParams { pub struct ConstructSpawnParams {
pub name: String, pub name: String,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct CrypLearnMsg { struct ConstructLearnMsg {
method: String, method: String,
params: CrypLearnParams, params: ConstructLearnParams,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct CrypLearnParams { pub struct ConstructLearnParams {
pub id: Uuid, pub id: Uuid,
pub skill: Skill, pub skill: Skill,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct CrypForgetParams { pub struct ConstructForgetParams {
pub id: Uuid, pub id: Uuid,
pub skill: Skill, pub skill: Skill,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct CrypForgetMsg { struct ConstructForgetMsg {
method: String, method: String,
params: CrypForgetParams, params: ConstructForgetParams,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct CrypUnspecParams { pub struct ConstructUnspecParams {
pub id: Uuid, pub id: Uuid,
pub spec: Spec, pub spec: Spec,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct CrypUnspecMsg { struct ConstructUnspecMsg {
method: String, method: String,
params: CrypUnspecParams, params: ConstructUnspecParams,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
@ -487,7 +487,7 @@ pub struct GameStateParams {
// #[derive(Debug,Clone,Serialize,Deserialize)] // #[derive(Debug,Clone,Serialize,Deserialize)]
// pub struct GamePveParams { // pub struct GamePveParams {
// pub cryp_ids: Vec<Uuid>, // pub construct_ids: Vec<Uuid>,
// } // }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
@ -499,8 +499,8 @@ struct GameSkillMsg {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct GameSkillParams { pub struct GameSkillParams {
pub game_id: Uuid, pub game_id: Uuid,
pub cryp_id: Uuid, pub construct_id: Uuid,
pub target_cryp_id: Option<Uuid>, pub target_construct_id: Option<Uuid>,
pub skill: Skill, pub skill: Skill,
} }
@ -529,7 +529,7 @@ pub struct AccountLoginParams {
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct AccountCrypsMsg { struct AccountConstructsMsg {
method: String, method: String,
params: (), params: (),
} }
@ -542,7 +542,7 @@ struct InstanceLobbyMsg {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct InstanceLobbyParams { pub struct InstanceLobbyParams {
pub cryp_ids: Vec<Uuid>, pub construct_ids: Vec<Uuid>,
pub name: String, pub name: String,
pub players: usize, pub players: usize,
pub password: Option<String>, pub password: Option<String>,
@ -557,7 +557,7 @@ struct InstanceJoinMsg {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct InstanceJoinParams { pub struct InstanceJoinParams {
pub instance_id: Uuid, pub instance_id: Uuid,
pub cryp_ids: Vec<Uuid>, pub construct_ids: Vec<Uuid>,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
@ -583,14 +583,14 @@ pub struct InstanceStateParams {
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
struct PlayerCrypsSetMsg { struct PlayerConstructsSetMsg {
method: String, method: String,
params: PlayerCrypsSetParams, params: PlayerConstructsSetParams,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct PlayerCrypsSetParams { pub struct PlayerConstructsSetParams {
pub cryp_ids: Vec<Uuid>, pub construct_ids: Vec<Uuid>,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
@ -638,7 +638,7 @@ struct VboxApplyMsg {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct VboxApplyParams { pub struct VboxApplyParams {
pub instance_id: Uuid, pub instance_id: Uuid,
pub cryp_id: Uuid, pub construct_id: Uuid,
pub index: usize, pub index: usize,
} }
@ -651,7 +651,7 @@ struct VboxUnequipMsg {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct VboxUnequipParams { pub struct VboxUnequipParams {
pub instance_id: Uuid, pub instance_id: Uuid,
pub cryp_id: Uuid, pub construct_id: Uuid,
pub target: Item, pub target: Item,
} }
@ -674,7 +674,7 @@ pub struct VboxReclaimParams {
// #[test] // #[test]
// fn rpc_parse() { // fn rpc_parse() {
// let rpc = Rpc {}; // let rpc = Rpc {};
// let msg = GenerateMsg { method: "cryp_generate".to_string(), params: GenerateParams { level: 64 } }; // let msg = GenerateMsg { method: "construct_generate".to_string(), params: GenerateParams { level: 64 } };
// let v = to_vec(&msg).unwrap(); // let v = to_vec(&msg).unwrap();
// let received = rpc.receive(Message::Binary(v)); // let received = rpc.receive(Message::Binary(v));
// } // }

View File

@ -2,7 +2,7 @@ use rand::{thread_rng, Rng};
use uuid::Uuid; use uuid::Uuid;
use util::{IntPct}; use util::{IntPct};
use cryp::{Cryp, CrypEffect, EffectMeta, Stat}; use construct::{Construct, ConstructEffect, EffectMeta, Stat};
use item::{Item}; use item::{Item};
use game::{Game}; use game::{Game};
@ -17,19 +17,19 @@ pub fn resolution_steps(cast: &Cast, game: &mut Game) -> Resolutions {
pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -> Resolutions { pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -> Resolutions {
let skill = cast.skill; let skill = cast.skill;
let source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone(); let source = game.construct_by_id(cast.source_construct_id).unwrap().clone();
let targets = game.get_targets(cast.skill, &source, cast.target_cryp_id); let targets = game.get_targets(cast.skill, &source, cast.target_construct_id);
if skill.aoe() { // Send an aoe skill event for anims if skill.aoe() { // Send an aoe skill event for anims
resolutions.push(Resolution::new(&source, &game.cryp_by_id(cast.target_cryp_id).unwrap().clone()).event(Event::AoeSkill { skill })); resolutions.push(Resolution::new(&source, &game.construct_by_id(cast.target_construct_id).unwrap().clone()).event(Event::AoeSkill { skill }));
} }
for target_id in targets { for target_id in targets {
// we clone the current state of the target and source // we clone the current state of the target and source
// so we can modify them during the resolution // so we can modify them during the resolution
// no more than 1 mutable ref allowed on game // no more than 1 mutable ref allowed on game
let mut source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone(); let mut source = game.construct_by_id(cast.source_construct_id).unwrap().clone();
let mut target = game.cryp_by_id(target_id).unwrap().clone(); let mut target = game.construct_by_id(target_id).unwrap().clone();
// bail out on ticks that have been removed // bail out on ticks that have been removed
if skill.is_tick() && target.effects.iter().find(|ce| match ce.tick { if skill.is_tick() && target.effects.iter().find(|ce| match ce.tick {
@ -42,8 +42,8 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -
resolutions = resolve(cast.skill, &mut source, &mut target, resolutions); resolutions = resolve(cast.skill, &mut source, &mut target, resolutions);
// save the changes to the game // save the changes to the game
game.update_cryp(&mut source); game.update_construct(&mut source);
game.update_cryp(&mut target); game.update_construct(&mut target);
// do additional steps // do additional steps
resolutions = post_resolve(cast.skill, game, resolutions); resolutions = post_resolve(cast.skill, game, resolutions);
@ -52,7 +52,7 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -
return resolutions; return resolutions;
} }
pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutions: Vec<Resolution>) -> Resolutions { pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut resolutions: Vec<Resolution>) -> Resolutions {
if let Some(disable) = source.disabled(skill) { if let Some(disable) = source.disabled(skill) {
resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill })); resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill }));
return resolutions; return resolutions;
@ -179,8 +179,8 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> Resolutions { fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> Resolutions {
for Resolution { source, target, event } in resolutions.clone() { for Resolution { source, target, event } in resolutions.clone() {
let mut source = game.cryp_by_id(source.id).unwrap().clone(); let mut source = game.construct_by_id(source.id).unwrap().clone();
let mut target = game.cryp_by_id(target.id).unwrap().clone(); let mut target = game.construct_by_id(target.id).unwrap().clone();
match event { match event {
Event::Damage { amount, skill, mitigation: _, colour: _ } => { Event::Damage { amount, skill, mitigation: _, colour: _ } => {
@ -208,8 +208,8 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) ->
_ => (), _ => (),
}; };
game.update_cryp(&mut source); game.update_construct(&mut source);
game.update_cryp(&mut target); game.update_construct(&mut target);
}; };
return resolutions; return resolutions;
@ -221,30 +221,30 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) ->
pub struct Cast { pub struct Cast {
pub id: Uuid, pub id: Uuid,
pub source_player_id: Uuid, pub source_player_id: Uuid,
pub source_cryp_id: Uuid, pub source_construct_id: Uuid,
pub target_cryp_id: Uuid, pub target_construct_id: Uuid,
pub skill: Skill, pub skill: Skill,
pub speed: u64, pub speed: u64,
} }
impl Cast { impl Cast {
pub fn new(source_cryp_id: Uuid, source_player_id: Uuid, target_cryp_id: Uuid, skill: Skill) -> Cast { pub fn new(source_construct_id: Uuid, source_player_id: Uuid, target_construct_id: Uuid, skill: Skill) -> Cast {
return Cast { return Cast {
id: Uuid::new_v4(), id: Uuid::new_v4(),
source_cryp_id, source_construct_id,
source_player_id, source_player_id,
target_cryp_id, target_construct_id,
skill, skill,
speed: 0, speed: 0,
}; };
} }
pub fn new_tick(source: &mut Cryp, target: &mut Cryp, skill: Skill) -> Cast { pub fn new_tick(source: &mut Construct, target: &mut Construct, skill: Skill) -> Cast {
Cast { Cast {
id: Uuid::new_v4(), id: Uuid::new_v4(),
source_cryp_id: source.id, source_construct_id: source.id,
source_player_id: source.account, source_player_id: source.account,
target_cryp_id: target.id, target_construct_id: target.id,
skill, skill,
speed: 0, speed: 0,
} }
@ -259,23 +259,23 @@ pub type Disable = Vec<Effect>;
pub type Immunity = Vec<Effect>; pub type Immunity = Vec<Effect>;
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub struct LogCryp { pub struct LogConstruct {
pub id: Uuid, pub id: Uuid,
pub name: String, pub name: String,
} }
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub struct Resolution { pub struct Resolution {
pub source: LogCryp, pub source: LogConstruct,
pub target: LogCryp, pub target: LogConstruct,
pub event: Event, pub event: Event,
} }
impl Resolution { impl Resolution {
fn new(source: &Cryp, target: &Cryp) -> Resolution { fn new(source: &Construct, target: &Construct) -> Resolution {
Resolution { Resolution {
source: LogCryp { id: source.id, name: source.name.clone() }, source: LogConstruct { id: source.id, name: source.name.clone() },
target: LogCryp { id: target.id, name: target.name.clone() }, target: LogConstruct { id: target.id, name: target.name.clone() },
event: Event::Incomplete, event: Event::Incomplete,
} }
} }
@ -641,49 +641,49 @@ impl Skill {
} }
} }
pub fn effect(&self) -> Vec<CrypEffect> { pub fn effect(&self) -> Vec<ConstructEffect> {
match self { match self {
// Modifiers // Modifiers
Skill::Amplify => vec![CrypEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], Skill::Amplify => vec![ConstructEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Banish => vec![CrypEffect {effect: Effect::Banish, duration: 1, meta: None, tick: None}], Skill::Banish => vec![ConstructEffect {effect: Effect::Banish, duration: 1, meta: None, tick: None}],
Skill::Block => vec![CrypEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}], Skill::Block => vec![ConstructEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}],
Skill::Buff => vec![CrypEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }], Skill::Buff => vec![ConstructEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }],
Skill::Corrupt => vec![CrypEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None}, Skill::Corrupt => vec![ConstructEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None},
CrypEffect {effect: Effect::Corruption, duration: 3, meta: None, tick: None}], ConstructEffect {effect: Effect::Corruption, duration: 3, meta: None, tick: None}],
Skill::Clutch => vec![CrypEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }], Skill::Clutch => vec![ConstructEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }],
Skill::Curse => vec![CrypEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], Skill::Curse => vec![ConstructEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Debuff => vec![CrypEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], Skill::Debuff => vec![ConstructEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }],
Skill::Decay => vec![CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }, Skill::Decay => vec![ConstructEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None },
CrypEffect {effect: Effect::Decay, duration: 3, meta: None, tick: None }], ConstructEffect {effect: Effect::Decay, duration: 3, meta: None, tick: None }],
Skill::Haste => vec![CrypEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }], Skill::Haste => vec![ConstructEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }],
Skill::Hex => vec![CrypEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}], Skill::Hex => vec![ConstructEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}],
Skill::Hostility => vec![CrypEffect {effect: Effect::Hostility, duration: 2, meta: None, tick: None}, Skill::Hostility => vec![ConstructEffect {effect: Effect::Hostility, duration: 2, meta: None, tick: None},
CrypEffect {effect: Effect::Hatred, duration: 5, meta: None, tick: None}], ConstructEffect {effect: Effect::Hatred, duration: 5, meta: None, tick: None}],
Skill::Impurity => vec![CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }], Skill::Impurity => vec![ConstructEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }],
Skill::Invert => vec![CrypEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}], Skill::Invert => vec![ConstructEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}],
Skill::Parry => vec![CrypEffect {effect: Effect::Parry, duration: 2, meta: None, tick: None }], Skill::Parry => vec![ConstructEffect {effect: Effect::Parry, duration: 2, meta: None, tick: None }],
Skill::Reflect => vec![CrypEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }], Skill::Reflect => vec![ConstructEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }],
Skill::Throw => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}, Skill::Throw => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None},
CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}], ConstructEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Ruin => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], Skill::Ruin => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}],
Skill::Scatter => vec![CrypEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}], Skill::Scatter => vec![ConstructEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}],
Skill::Silence => vec![CrypEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}], Skill::Silence => vec![ConstructEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}],
Skill::Siphon => vec![CrypEffect {effect: Effect::Siphon, duration: 2, meta: None, tick: None}], Skill::Siphon => vec![ConstructEffect {effect: Effect::Siphon, duration: 2, meta: None, tick: None}],
Skill::Sleep => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], Skill::Sleep => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}],
Skill::Snare => vec![CrypEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}], Skill::Snare => vec![ConstructEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}],
Skill::Strangle => vec![CrypEffect {effect: Effect::Strangle, duration: 2, meta: None, tick: None}], Skill::Strangle => vec![ConstructEffect {effect: Effect::Strangle, duration: 2, meta: None, tick: None}],
Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], Skill::Stun => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}],
Skill::Taunt => vec![CrypEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}], Skill::Taunt => vec![ConstructEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}],
Skill::Triage => vec![CrypEffect {effect: Effect::Triage, duration: 2, meta: None, tick: None}], Skill::Triage => vec![ConstructEffect {effect: Effect::Triage, duration: 2, meta: None, tick: None}],
//Unused //Unused
Skill::Injure => vec![CrypEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }], Skill::Injure => vec![ConstructEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }],
_ => { _ => {
panic!("{:?} no skill effect", self); panic!("{:?} no skill effect", self);
@ -876,7 +876,7 @@ impl Skill {
} }
} }
fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn touch(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
target.deal_red_damage(skill, 0) target.deal_red_damage(skill, 0)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
@ -884,7 +884,7 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn attack(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
@ -893,7 +893,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn strike(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
@ -902,7 +902,7 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
@ -914,14 +914,14 @@ fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn stun(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn sleep(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
@ -933,13 +933,13 @@ fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn clutch(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn taunt(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let red_amount = source.red_damage().pct(skill.multiplier()); let red_amount = source.red_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0)));
@ -948,27 +948,27 @@ fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn throw(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn strangle(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| { skill.effect().into_iter().for_each(|e| {
let CrypEffect { effect: _, duration, meta: _, tick: _ } = e; let ConstructEffect { effect: _, duration, meta: _, tick: _ } = e;
let strangle = e.clone().set_tick(Cast::new_tick(source, target, Skill::StrangleTick)); let strangle = e.clone().set_tick(Cast::new_tick(source, target, Skill::StrangleTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, strangle))); results.push(Resolution::new(source, target).event(target.add_effect(skill, strangle)));
let attacker_strangle = CrypEffect::new(Effect::Strangling, duration); let attacker_strangle = ConstructEffect::new(Effect::Strangling, duration);
results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_strangle))); results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_strangle)));
}); });
return strangle_tick(source, target, results, Skill::StrangleTick); return strangle_tick(source, target, results, Skill::StrangleTick);
} }
fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
@ -979,7 +979,7 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions,
let i = source.effects let i = source.effects
.iter() .iter()
.position(|e| e.effect == Effect::Strangling) .position(|e| e.effect == Effect::Strangling)
.expect("no strangling on cryp"); .expect("no strangling on construct");
source.effects.remove(i); source.effects.remove(i);
results.push(Resolution::new(source, source).event(Event::Removal { effect: Effect::Strangling })); results.push(Resolution::new(source, source).event(Event::Removal { effect: Effect::Strangling }));
} }
@ -987,19 +987,19 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions,
return results; return results;
} }
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn block(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn buff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn buff(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn parry(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let red_amount = source.red_damage().pct(skill.multiplier()); let red_amount = source.red_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0)));
@ -1008,7 +1008,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn riposte(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
@ -1017,7 +1017,7 @@ fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
return results; return results;
} }
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn snare(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
@ -1037,7 +1037,7 @@ fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn slay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn slay(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier()); let amount = source.red_damage().pct(skill.multiplier());
let slay_events = target.deal_red_damage(skill, amount); let slay_events = target.deal_red_damage(skill, amount);
@ -1057,7 +1057,7 @@ fn slay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: S
return results; return results;
} }
fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn heal(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.green_damage().pct(skill.multiplier()); let amount = source.green_damage().pct(skill.multiplier());
target.deal_green_damage(skill, amount) target.deal_green_damage(skill, amount)
.into_iter() .into_iter()
@ -1065,7 +1065,7 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: S
return results; return results;
} }
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn triage(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| { skill.effect().into_iter().for_each(|e| {
let triage = e.clone().set_tick(Cast::new_tick(source, target, Skill::TriageTick)); let triage = e.clone().set_tick(Cast::new_tick(source, target, Skill::TriageTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, triage))); results.push(Resolution::new(source, target).event(target.add_effect(skill, triage)));
@ -1074,7 +1074,7 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return triage_tick(source, target, results, Skill::TriageTick); return triage_tick(source, target, results, Skill::TriageTick);
} }
fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn triage_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.green_damage().pct(skill.multiplier()); let amount = source.green_damage().pct(skill.multiplier());
target.deal_green_damage(Skill::TriageTick, amount) target.deal_green_damage(Skill::TriageTick, amount)
.into_iter() .into_iter()
@ -1082,7 +1082,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s
return results; return results;
} }
fn chaos(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn chaos(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let mut rng = thread_rng(); let mut rng = thread_rng();
let b_rng: u64 = rng.gen_range(0, 30); let b_rng: u64 = rng.gen_range(0, 30);
let amount = source.blue_damage().pct(skill.multiplier() + b_rng); let amount = source.blue_damage().pct(skill.multiplier() + b_rng);
@ -1097,7 +1097,7 @@ fn chaos(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn blast(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier()); let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount) target.deal_blue_damage(skill, amount)
.into_iter() .into_iter()
@ -1105,28 +1105,28 @@ fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn amplify(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn haste(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn debuff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn debuff(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn decay(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| { skill.effect().into_iter().for_each(|e| {
let CrypEffect { effect, duration: _, meta: _, tick: _ } = e; let ConstructEffect { effect, duration: _, meta: _, tick: _ } = e;
let apply_effect = match effect { let apply_effect = match effect {
Effect::Wither => e.clone(), Effect::Wither => e.clone(),
Effect::Decay => e.clone().set_tick(Cast::new_tick(source, target, Skill::DecayTick)), Effect::Decay => e.clone().set_tick(Cast::new_tick(source, target, Skill::DecayTick)),
@ -1138,7 +1138,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return decay_tick(source, target, results, Skill::DecayTick); return decay_tick(source, target, results, Skill::DecayTick);
} }
fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn decay_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier()); let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount) target.deal_blue_damage(skill, amount)
.into_iter() .into_iter()
@ -1148,13 +1148,13 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk
// corrupt is the buff effect // corrupt is the buff effect
// when attacked it runs corruption and applies a debuff // when attacked it runs corruption and applies a debuff
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn corrupt(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let corrupt = skill.effect().first().unwrap().clone(); let corrupt = skill.effect().first().unwrap().clone();
results.push(Resolution::new(source, target).event(target.add_effect(skill, corrupt))); results.push(Resolution::new(source, target).event(target.add_effect(skill, corrupt)));
return results;; return results;;
} }
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn corruption(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let corruption = skill.effect().last().unwrap().clone() let corruption = skill.effect().last().unwrap().clone()
.set_tick(Cast::new_tick(source, target, Skill::CorruptionTick)); .set_tick(Cast::new_tick(source, target, Skill::CorruptionTick));
@ -1162,7 +1162,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk
return corruption_tick(source, target, results, Skill::CorruptionTick); return corruption_tick(source, target, results, Skill::CorruptionTick);
} }
fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn corruption_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier()); let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount) target.deal_blue_damage(skill, amount)
.into_iter() .into_iter()
@ -1170,26 +1170,26 @@ fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolution
return results; return results;
} }
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn ruin(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn hex(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn hostility(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let hostility = skill.effect().first().unwrap().clone(); let hostility = skill.effect().first().unwrap().clone();
results.push(Resolution::new(source, target).event(target.add_effect(skill, hostility))); results.push(Resolution::new(source, target).event(target.add_effect(skill, hostility)));
return results;; return results;;
} }
fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions { fn hatred(source: &mut Construct, target: &mut Construct, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions {
let hatred = skill.effect().last().unwrap().clone() let hatred = skill.effect().last().unwrap().clone()
.set_meta(EffectMeta::AddedDamage(amount)); .set_meta(EffectMeta::AddedDamage(amount));
@ -1197,25 +1197,25 @@ fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflec
return results;; return results;;
} }
fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn curse(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn impurity(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn impurity(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn invert(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn reflect(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
@ -1225,7 +1225,7 @@ fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
return results;; return results;;
} }
fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn recharge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let red_amount = source.red_damage().pct(skill.multiplier()); let red_amount = source.red_damage().pct(skill.multiplier());
let blue_amount = source.blue_damage().pct(skill.multiplier()); let blue_amount = source.blue_damage().pct(skill.multiplier());
@ -1233,7 +1233,7 @@ fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skil
return results; return results;
} }
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn siphon(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| { skill.effect().into_iter().for_each(|e| {
let siphon = e.clone().set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); let siphon = e.clone().set_tick(Cast::new_tick(source, target, Skill::SiphonTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon))); results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon)));
@ -1242,7 +1242,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return siphon_tick(source, target, results, Skill::SiphonTick); return siphon_tick(source, target, results, Skill::SiphonTick);
} }
fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn siphon_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier()); let amount = source.blue_damage().pct(skill.multiplier());
let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount);
@ -1262,7 +1262,7 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s
return results; return results;
} }
fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn scatter(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
let blue_amount = source.blue_damage().pct(skill.multiplier()); let blue_amount = source.blue_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount)));
@ -1274,13 +1274,13 @@ fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
return results; return results;
} }
fn scatter_hit(source: &Cryp, target: &Cryp, mut results: Resolutions, game: &mut Game, event: Event) -> Resolutions { fn scatter_hit(source: &Construct, target: &Construct, mut results: Resolutions, game: &mut Game, event: Event) -> Resolutions {
match event { match event {
Event::Damage { amount, skill, mitigation: _, colour } => { Event::Damage { amount, skill, mitigation: _, colour } => {
let scatter = target.effects.iter().find(|e| e.effect == Effect::Scatter).unwrap(); let scatter = target.effects.iter().find(|e| e.effect == Effect::Scatter).unwrap();
if let Some(EffectMeta::ScatterTarget(scatter_target_id)) = scatter.meta { if let Some(EffectMeta::ScatterTarget(scatter_target_id)) = scatter.meta {
let mut scatter_target = game.cryp_by_id(scatter_target_id).unwrap(); let mut scatter_target = game.construct_by_id(scatter_target_id).unwrap();
let res = match colour { let res = match colour {
Colour::Red => scatter_target.deal_red_damage(skill, amount), Colour::Red => scatter_target.deal_red_damage(skill, amount),
@ -1300,7 +1300,7 @@ fn scatter_hit(source: &Cryp, target: &Cryp, mut results: Resolutions, game: &mu
} }
} }
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn silence(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
@ -1319,7 +1319,7 @@ fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
return results; return results;
} }
fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, _skill: Skill) -> Resolutions { fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, _skill: Skill) -> Resolutions {
while let Some(i) = target.effects while let Some(i) = target.effects
.iter() .iter()
.position(|ce| ce.effect.category() == EffectCategory::Buff) { .position(|ce| ce.effect.category() == EffectCategory::Buff) {
@ -1330,7 +1330,7 @@ fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, _skill:
return results; return results;
} }
fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
results.push(Resolution::new(source, target).event(Event::Skill { skill })); results.push(Resolution::new(source, target).event(Event::Skill { skill }));
let amount = source.green_damage().pct(skill.multiplier()); let amount = source.green_damage().pct(skill.multiplier());
while let Some(i) = target.effects while let Some(i) = target.effects
@ -1346,7 +1346,7 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
return results; return results;
} }
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn banish(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter() skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
@ -1358,11 +1358,11 @@ mod tests {
#[test] #[test]
fn heal_test() { fn heal_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()) .named(&"muji".to_string())
.learn(Skill::Heal); .learn(Skill::Heal);
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()) .named(&"camel".to_string())
.learn(Skill::Heal); .learn(Skill::Heal);
@ -1373,10 +1373,10 @@ mod tests {
#[test] #[test]
fn decay_test() { fn decay_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
decay(&mut x, &mut y, vec![], Skill::Decay); decay(&mut x, &mut y, vec![], Skill::Decay);
@ -1390,10 +1390,10 @@ mod tests {
#[test] #[test]
fn block_test() { fn block_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
// ensure it doesn't have 0 pd // ensure it doesn't have 0 pd
@ -1414,10 +1414,10 @@ mod tests {
#[test] #[test]
fn clutch_test() { fn clutch_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
x.red_damage.force(10000000000000); // multiplication of int max will cause overflow x.red_damage.force(10000000000000); // multiplication of int max will cause overflow
@ -1444,10 +1444,10 @@ mod tests {
#[test] #[test]
fn injure_test() { fn injure_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
resolve(Skill::Injure, &mut x, &mut y, vec![]); resolve(Skill::Injure, &mut x, &mut y, vec![]);
@ -1457,10 +1457,10 @@ mod tests {
#[test] #[test]
fn invert_test() { fn invert_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
// give red shield but reduce to 0 // give red shield but reduce to 0
@ -1496,10 +1496,10 @@ mod tests {
#[test] #[test]
fn reflect_test() { fn reflect_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
reflect(&mut y.clone(), &mut y, vec![], Skill::Reflect); reflect(&mut y.clone(), &mut y, vec![], Skill::Reflect);
@ -1525,10 +1525,10 @@ mod tests {
#[test] #[test]
fn siphon_test() { fn siphon_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"camel".to_string()); .named(&"camel".to_string());
x.green_life.reduce(512); x.green_life.reduce(512);
@ -1562,10 +1562,10 @@ mod tests {
#[test] #[test]
fn triage_test() { fn triage_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"pretaliation".to_string()); .named(&"pretaliation".to_string());
// ensure it doesn't have 0 sd // ensure it doesn't have 0 sd
@ -1586,10 +1586,10 @@ mod tests {
#[test] #[test]
fn recharge_test() { fn recharge_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
let mut y = Cryp::new() let mut y = Construct::new()
.named(&"pretaliation".to_string()); .named(&"pretaliation".to_string());
y.red_life.force(50); y.red_life.force(50);
@ -1613,7 +1613,7 @@ mod tests {
#[test] #[test]
fn silence_test() { fn silence_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
silence(&mut x.clone(), &mut x, vec![], Skill::Silence); silence(&mut x.clone(), &mut x, vec![], Skill::Silence);
@ -1623,7 +1623,7 @@ mod tests {
#[test] #[test]
fn amplify_test() { fn amplify_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
x.blue_damage.force(50); x.blue_damage.force(50);
@ -1635,7 +1635,7 @@ mod tests {
#[test] #[test]
fn purify_test() { fn purify_test() {
let mut x = Cryp::new() let mut x = Construct::new()
.named(&"muji".to_string()); .named(&"muji".to_string());
decay(&mut x.clone(), &mut x, vec![], Skill::Decay); decay(&mut x.clone(), &mut x, vec![], Skill::Decay);

View File

@ -1,4 +1,4 @@
use cryp::{Stat, Colours}; use construct::{Stat, Colours};
use util::{IntPct}; use util::{IntPct};
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
@ -59,8 +59,8 @@ impl Spec {
} }
} }
pub fn apply(&self, modified: u64, base: u64, cryp_colours: &Colours, player_colours: &Colours) -> u64 { pub fn apply(&self, modified: u64, base: u64, construct_colours: &Colours, player_colours: &Colours) -> u64 {
let cryp_colour_total: u64 = (cryp_colours.red + cryp_colours.green + cryp_colours.blue) as u64; let construct_colour_total: u64 = (construct_colours.red + construct_colours.green + construct_colours.blue) as u64;
match *self { match *self {
// Upgrades to Damage Spec // Upgrades to Damage Spec
Spec::Damage => modified + base.pct(5), Spec::Damage => modified + base.pct(5),
@ -157,42 +157,42 @@ impl Spec {
if player_colours.green >= 5 { mult += 15 }; if player_colours.green >= 5 { mult += 15 };
if player_colours.green >= 10 { mult += 30 }; if player_colours.green >= 10 { mult += 30 };
if player_colours.green >= 20 { mult += 45 }; if player_colours.green >= 20 { mult += 45 };
mult * cryp_colour_total mult * construct_colour_total
}, },
Spec::RedLifeI => modified + { Spec::RedLifeI => modified + {
let mut mult: u64 = 25; let mut mult: u64 = 25;
if player_colours.red >= 5 { mult += 15 }; if player_colours.red >= 5 { mult += 15 };
if player_colours.red >= 10 { mult += 30 }; if player_colours.red >= 10 { mult += 30 };
if player_colours.red >= 20 { mult += 45 }; if player_colours.red >= 20 { mult += 45 };
mult * cryp_colour_total mult * construct_colour_total
}, },
Spec::BlueLifeI => modified + { Spec::BlueLifeI => modified + {
let mut mult: u64 = 25; let mut mult: u64 = 25;
if player_colours.blue >= 5 { mult += 15 }; if player_colours.blue >= 5 { mult += 15 };
if player_colours.blue >= 10 { mult += 30 }; if player_colours.blue >= 10 { mult += 30 };
if player_colours.blue >= 20 { mult += 45 }; if player_colours.blue >= 20 { mult += 45 };
mult * cryp_colour_total mult * construct_colour_total
}, },
Spec::GRLI => modified + { Spec::GRLI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * cryp_colour_total mult * construct_colour_total
}, },
Spec::GBLI => modified + { Spec::GBLI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * cryp_colour_total mult * construct_colour_total
}, },
Spec::RBLI => modified + { Spec::RBLI => modified + {
let mut mult: u64 = 15; let mut mult: u64 = 15;
if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 }; if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 };
mult * cryp_colour_total mult * construct_colour_total
}, },
} }
} }

View File

@ -13,7 +13,7 @@ use failure::err_msg;
use account::Account; use account::Account;
use rpc::{VboxAcceptParams, VboxDiscardParams, VboxCombineParams, VboxApplyParams, VboxReclaimParams, VboxUnequipParams}; use rpc::{VboxAcceptParams, VboxDiscardParams, VboxCombineParams, VboxApplyParams, VboxReclaimParams, VboxUnequipParams};
use instance::{Instance, instance_get, instance_update}; use instance::{Instance, instance_get, instance_update};
use cryp::{Colours}; use construct::{Colours};
use item::*; use item::*;
@ -181,13 +181,13 @@ pub fn vbox_reclaim(params: VboxReclaimParams, tx: &mut Transaction, account: &A
pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> { pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
let instance = instance_get(tx, params.instance_id)? let instance = instance_get(tx, params.instance_id)?
.vbox_apply(account.id, params.index, params.cryp_id)?; .vbox_apply(account.id, params.index, params.construct_id)?;
return instance_update(tx, instance); return instance_update(tx, instance);
} }
pub fn vbox_unequip(params: VboxUnequipParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> { pub fn vbox_unequip(params: VboxUnequipParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
let instance = instance_get(tx, params.instance_id)? let instance = instance_get(tx, params.instance_id)?
.vbox_unequip(account.id, params.target, params.cryp_id)?; .vbox_unequip(account.id, params.target, params.construct_id)?;
return instance_update(tx, instance); return instance_update(tx, instance);
} }

View File

@ -101,7 +101,7 @@ pub fn zone_get(tx: &mut Transaction, id: Uuid) -> Result<Zone, Error> {
None => return Err(err_msg("zone not found")), None => return Err(err_msg("zone not found")),
}; };
// tells from_slice to cast into a cryp // tells from_slice to cast into a construct
let bytes: Vec<u8> = returned.get("data"); let bytes: Vec<u8> = returned.get("data");
let zone = match from_slice::<Zone>(&bytes) { let zone = match from_slice::<Zone>(&bytes) {
Ok(z) => z, Ok(z) => z,
@ -180,7 +180,7 @@ pub fn zone_join(params: ZoneJoinParams, tx: &mut Transaction, account: &Account
"BOSS" => GameMode::Zone3v3HealerBoss, "BOSS" => GameMode::Zone3v3HealerBoss,
_ => return Err(err_msg("unknown zone tag")), _ => return Err(err_msg("unknown zone tag")),
}; };
game = game_pve_new(params.cryp_ids, mode, tx, account)?; game = game_pve_new(params.construct_ids, mode, tx, account)?;
game.set_zone(zone.id, params.node_id); game.set_zone(zone.id, params.node_id);
encounter.game_id = Some(game.id); encounter.game_id = Some(game.id);