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"
|
||||
"Mercedes"
|
||||
"Merryl"
|
||||
"Mii’a"
|
||||
"Mii'a"
|
||||
"Niels"
|
||||
"Nina"
|
||||
"Rami"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import "math/observable" for Observable
|
||||
import "luxe: world" for Entity, Values, Tags
|
||||
import "globals" for Globals
|
||||
import "blocks/resources" for Resources
|
||||
|
||||
class Adventures{
|
||||
planning{_planning}
|
||||
|
|
@ -45,7 +46,7 @@ class Adventure{
|
|||
|
||||
construct new(){
|
||||
_adventurers = []
|
||||
_resources = []
|
||||
_resources = Resources.new()
|
||||
_data = {}
|
||||
|
||||
_direction = 0
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import "luxe: world" for Entity
|
|||
import "math/event" for Event
|
||||
import "math/observable" for Observable
|
||||
import "math/stringUtil" for StringUtil
|
||||
import "math/util" for Actions
|
||||
|
||||
class Resources is Observable{
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ class Resources is Observable{
|
|||
add(resource, -amount)
|
||||
}
|
||||
|
||||
empty(resource){
|
||||
clear(resource){
|
||||
var value = get(resource)
|
||||
if(value > 0){ //this check is to not initialize undefined resource types
|
||||
set(resource, 0)
|
||||
|
|
@ -55,6 +56,25 @@ class Resources is Observable{
|
|||
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){
|
||||
if(has(resource, amount)){
|
||||
remove(resource, amount)
|
||||
|
|
@ -66,6 +86,6 @@ class Resources is Observable{
|
|||
|
||||
has(resource, amount){
|
||||
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
|
||||
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)
|
||||
Control.set_size(slider, 7, -1)
|
||||
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|
|
||||
if(event.type == UIEvent.change){
|
||||
var position = 0
|
||||
|
|
|
|||
|
|
@ -104,4 +104,27 @@ class Util{
|
|||
|
||||
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