minor stuff that breaks something ?!?
This commit is contained in:
parent
83c0a2168a
commit
a29bb45053
6 changed files with 50 additions and 6 deletions
|
|
@ -35,7 +35,7 @@
|
||||||
"Mara"
|
"Mara"
|
||||||
"Mercedes"
|
"Mercedes"
|
||||||
"Merryl"
|
"Merryl"
|
||||||
"Mii’a"
|
"Mii'a"
|
||||||
"Niels"
|
"Niels"
|
||||||
"Nina"
|
"Nina"
|
||||||
"Rami"
|
"Rami"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import "math/observable" for Observable
|
import "math/observable" for Observable
|
||||||
import "luxe: world" for Entity, Values, Tags
|
import "luxe: world" for Entity, Values, Tags
|
||||||
import "globals" for Globals
|
import "globals" for Globals
|
||||||
|
import "blocks/resources" for Resources
|
||||||
|
|
||||||
class Adventures{
|
class Adventures{
|
||||||
planning{_planning}
|
planning{_planning}
|
||||||
|
|
@ -45,7 +46,7 @@ class Adventure{
|
||||||
|
|
||||||
construct new(){
|
construct new(){
|
||||||
_adventurers = []
|
_adventurers = []
|
||||||
_resources = []
|
_resources = Resources.new()
|
||||||
_data = {}
|
_data = {}
|
||||||
|
|
||||||
_direction = 0
|
_direction = 0
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import "luxe: world" for Entity
|
||||||
import "math/event" for Event
|
import "math/event" for Event
|
||||||
import "math/observable" for Observable
|
import "math/observable" for Observable
|
||||||
import "math/stringUtil" for StringUtil
|
import "math/stringUtil" for StringUtil
|
||||||
|
import "math/util" for Actions
|
||||||
|
|
||||||
class Resources is Observable{
|
class Resources is Observable{
|
||||||
|
|
||||||
|
|
@ -47,7 +48,7 @@ class Resources is Observable{
|
||||||
add(resource, -amount)
|
add(resource, -amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
empty(resource){
|
clear(resource){
|
||||||
var value = get(resource)
|
var value = get(resource)
|
||||||
if(value > 0){ //this check is to not initialize undefined resource types
|
if(value > 0){ //this check is to not initialize undefined resource types
|
||||||
set(resource, 0)
|
set(resource, 0)
|
||||||
|
|
@ -55,6 +56,25 @@ class Resources is Observable{
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
empty(resource){
|
||||||
|
return !has(resource, 1) //returns true if resource doesn't exist or is 0 (or negative??)
|
||||||
|
}
|
||||||
|
|
||||||
|
exists(resource){
|
||||||
|
return _resources.containsKey(resource)
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEmpty(){
|
||||||
|
for(key in _resources.keys){
|
||||||
|
if(empty(key)){
|
||||||
|
Actions.queue{
|
||||||
|
_resources.remove(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Actions.execute()
|
||||||
|
}
|
||||||
|
|
||||||
tryRemove(resource, amount){
|
tryRemove(resource, amount){
|
||||||
if(has(resource, amount)){
|
if(has(resource, amount)){
|
||||||
remove(resource, amount)
|
remove(resource, amount)
|
||||||
|
|
@ -66,6 +86,6 @@ class Resources is Observable{
|
||||||
|
|
||||||
has(resource, amount){
|
has(resource, amount){
|
||||||
var value = _resources[resource]
|
var value = _resources[resource]
|
||||||
return value && value >= amount //check if not null, and bigger than amount
|
return value && value >= amount //check if not null, and bigger/equal than amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ class Tooltip{
|
||||||
|
|
||||||
var offsets = shadowOffsets
|
var offsets = shadowOffsets
|
||||||
for(i in 0...offsets.count){
|
for(i in 0...offsets.count){
|
||||||
Transform.set_pos(_shadows[i], pos.x+offsets[i].x, pos.y+offsets[i].y, depth-10)
|
Transform.set_pos(_shadows[i], pos.x+offsets[i].x, pos.y+offsets[i].y, depth-5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class UiScrollBox{
|
||||||
UiSlider.set_value(slider, 0)
|
UiSlider.set_value(slider, 0)
|
||||||
Control.set_size(slider, 7, -1)
|
Control.set_size(slider, 7, -1)
|
||||||
UILayout.set_behave(ent, slider, UILayoutBehave.right | UILayoutBehave.vfill) //|
|
UILayout.set_behave(ent, slider, UILayoutBehave.right | UILayoutBehave.vfill) //|
|
||||||
UILayout.set_margin(ent, slider, 1, 0, 1, 0)
|
UILayout.set_margin(ent, slider, -1, 0, 0, 0)
|
||||||
Control.set_events(slider){|event|
|
Control.set_events(slider){|event|
|
||||||
if(event.type == UIEvent.change){
|
if(event.type == UIEvent.change){
|
||||||
var position = 0
|
var position = 0
|
||||||
|
|
|
||||||
|
|
@ -104,4 +104,27 @@ class Util{
|
||||||
|
|
||||||
return col.toList + [1]
|
return col.toList + [1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Actions{
|
||||||
|
|
||||||
|
static actions{
|
||||||
|
System.print(__actions)
|
||||||
|
if(!__actions) __actions = []
|
||||||
|
System.print(__actions)
|
||||||
|
return __actions
|
||||||
|
}
|
||||||
|
|
||||||
|
static queue(fn){
|
||||||
|
actions.add(fn)
|
||||||
|
System.print("actions are %(actions)")
|
||||||
|
}
|
||||||
|
|
||||||
|
static execute(){
|
||||||
|
actions.each{|action|
|
||||||
|
action.call()
|
||||||
|
}
|
||||||
|
actions.clear()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue