The 2nd Monitor

General discussion about codereview.stackexchange.com - Welcom...
Aug 31, 2014 17:06
hard enough to get Lua shit reviewed, better to leave the simple stuff alone
Aug 31, 2014 17:06
second one adds a bunch of stuff that's harder to understand
Aug 31, 2014 17:05
the first one will be easier to digest/review
Aug 31, 2014 17:05
@SimonAndréForsberg because it's a big change
 

 Coding Projects and Duga Heaven :)

Minesweeper Flags, Zomis' games, PDB, MTG, Cardshifter, and al...
Aug 31, 2014 15:22
the ECS can hold its own but still having a hard time visualizing how it will be used with a TCG exactly. Feel free to use it though.
Aug 31, 2014 15:20
with the Lua ECS thing
Aug 31, 2014 15:20
i made pong
Aug 31, 2014 15:20
Aug 31, 2014 01:21
The SVG files themselves would be part of the mod, sent to the client at the beginning of the game (there would probably only be one or two "templates" for an entire game), so there is no problem with the results of getDisplayProperties (or whatever) matching the placeholder values in the SVG
Aug 31, 2014 01:19
Each card would have a function named something like getDisplayProperties, and this would return a table with just the stuff the UI needs to display the card. This table gets sent over the wire, and the UI drops the properties of the table into an SVG template... for example if the tables have "name," "description," "health," and "defense" properties, the SVG files would have matching tokens like {name} and {health}, and the data would be inserted with simple replacement
Aug 31, 2014 01:17
@SimonAndréForsberg I think this might be more a matter of which properties should be sent to the client. The only thing the client needs to work with the card is an ID, and then it needs some properties to display. I was imagining this working like this...
Aug 30, 2014 17:30
i think this is the equivalent of what i tried to write above in Java (and probably failed miserably)
Aug 30, 2014 17:26
function each(javacrap)
  local iterator = javacrap:iterator()
  return function()
    if iterator:hasNext() then
      return iterator:next()
    else
      return nil
    end
  end
end
Aug 30, 2014 17:26
like
Aug 30, 2014 17:26
could we cheat and just dump a Lua function in a string on the Java side
Aug 30, 2014 17:12
wouldn't bet on it, but no clue really
Aug 30, 2014 17:11
or if we need zone.getCards on the Java end, make another function named something like that to do this
Aug 30, 2014 17:11
so that in lua we can do: for card in zone:getCards() do
Aug 30, 2014 17:10
i want to turn zone.getCards into a function that returns a Lua iterator function
Aug 30, 2014 17:09
how would this look if it did not look horrible?
Aug 30, 2014 17:08
but... umm... yeah
Aug 30, 2014 17:08
lol, it looks horrible to me
Aug 30, 2014 17:07
abstract class LuaCardIterator extends ZeroArgFunction {
    public LuaValue call();
}

public class LuaCardIteratorFactory extends ZeroArgFunction {

    private ListIterator<Card> iterator = field.getCards().iterator();

    public void call() {
        return new LuaCardIterator() {
            public void call() {
                if (iterator.hasNext()) {
                    return iterator.next()
                } else {
                    return LuaNil
                }
            }
        };
Aug 30, 2014 17:07
would it look anything like this:
Aug 30, 2014 17:07
@SimonAndréForsberg how do you define a Lua function that returns another Lua function in Java?
Aug 30, 2014 16:29
field:eachCard() would return a function that returns each card in succession
Aug 30, 2014 16:28
wouldn't even need to make a table, just have a special iterator that returns one card after another until none are left
Aug 30, 2014 16:28
what about something like that
Aug 30, 2014 16:27
for card in field:eachCard() do
    if card.data.sickness > 0 then
        card.data.sickness = card.data.sickness - 1
        print("Card on field now has sickness" .. card.data.sickness)
    end
    card.data.attacksAvailable = 1
end
Aug 30, 2014 16:26
inserting is no problem, shuffling can be a simple fisher-yates which is like 4 LOC
Aug 30, 2014 16:22
just something to get rid of the weird linked list iterators
Aug 30, 2014 16:22
really the current system would be fine with me if there were a public zone.cards or something that ipairs could operate on
Aug 30, 2014 16:15
zone = setmetatable({}, { __newindex = function() ... end })
Aug 30, 2014 16:14
have a metamethod on your "zone" tables that does all that when you insert new stuff
Aug 30, 2014 16:13
with metamethods
Aug 30, 2014 16:13
i think it could though
Aug 30, 2014 16:12
true, true
Aug 30, 2014 16:10
table.insert(x, card) is well documented and many people are already familiar with it
Aug 30, 2014 16:10
card:moveToBottomOf(x) is something that nobody already knows
Aug 30, 2014 16:09
and will a Lua IDE really find this stuff that was defined in Java?
Aug 30, 2014 16:08
maybe this is a cultural thing then... i rarely use an IDE, i use text editors for light stuff and vim for heavy stuff
Aug 30, 2014 16:03
either that or something like card.zone = owner.data.battlefield
Aug 30, 2014 16:02
i should be able to do this: table.insert(owner.data.battlefield, card)
Aug 30, 2014 16:02
i should not have to remember that here's a function named card:moveToBottomOf
Aug 30, 2014 15:51
just like if we do ECS on the script side. It's not something proscribed, it's more like an example that people can follow, or not
Aug 30, 2014 15:50
if it were all on the script side, it would be more like "this is how we do zones in this game, you can use this, or do something similar, or just do whatever"
Aug 30, 2014 15:49
and i don't just mean game:addZone and card:getZone, i mean the whole iterator API that comes with it... all that adds complexity, more specific stuff to know
Aug 30, 2014 15:48
and not just deal with them however they want
Aug 30, 2014 15:48
if you are having the script deal with zones anyway, then you are adding complexity by having the script also have to deal with them through a special API
Aug 30, 2014 15:47
here's how i look at it... you put stuff in the core that it needs to handle, like communicating with the client, and stuff that you don't want the script to have to deal with, because it's too low level