Closed tbeddy closed 7 years ago
The use of sets for :can-repair in data.cljs is good, but they needed to be loaded into the DataScript DB a little differently. Each item in the set should result in a datom attached to the unit type entity in the DB. The closest analog for how this should work is :unit-type/zoc-armor-types.
I'm not familiar with DataScript, so I'm having some trouble with this. Should I be altering the schema as defined in db.cljs?
Yep, attributes with cardinality > 1 need schema entries. It should look something like this: https://github.com/Zetawar/zetawar/blob/5672efd67f8b8a2a06e5e67911d83c32cc039b6f/src/cljs/zetawar/db.cljs#L56
Is that last commit closer?
On a different note, are you okay with two of the repair functions I added in game.cljs (can-be-repaired? and compatible-armor-types-for-repair?) not following the check-next-state model you use for can-repair?, can-attack?, etc.?
You mean should a unit be able to repair another unit regardless of what state the other unit is in? If that's the question, I'd say yes.
I mean should a unit have to check its state at all to be able to repair another unit.
can-be-repaired? is currently...
(defn can-be-repaired? [db game unit] (< (:unit/count unit) (:game/max-count-per-unit game)))
(which doesn't use the database at all)
...instead of something like...
(defn can-be-repaired? [db game unit] (try (check-can-be-repaired db game unit) true (catch :default ex false)))
...which is how most of the surrounding functions have been designed.
Ah, I see what you mean. It doesn't really need to check the state, but it probably should work the same way as 'check-in-range' where there is both a 'check' version that throws an exception and a '?' version that returns a value. That way you can call the 'check' version in the 'repair-other-tx' as an assertion.
I adapted those functions. Let me know if they look alright and anything else you'd like worked on when you have the chance.
I'm traveling now, so it might be a few days before I can take a look. But I'll check it out as soon as I get a chance.
Merged. Thanks for all your work on this! I'll get started on a review/cleanup branch soon and ping you when it's ready.
Cool, thanks for all your help.
This allows specific unit types to repair other units. Currently only the medic is able to do so. Images have been added for the medic unit-type, along with an image to highlight the border of targeted friendly units in green. Bugs include medics being unable to repair others after moving once and inconsistent tile-masking. Update: I've fixed the first bug. The tile-masking is improved, though probably not ideal.