laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter>
<girng> hello
<FromGitter>
<tenebrousedge> how's?
<FromGitter>
<girng> @tenebrousedge good how about you?
<FromGitter>
<tenebrousedge> probably good. Pondering API metadata in redux
<FromGitter>
<girng> nice
<FromGitter>
<girng> are you making a project with redux and crystal together?
<FromGitter>
<tenebrousedge> no, it's trivial enough to not need a backend. But there are a dozen similar ways to do any given thing in react/redux world, and I'm not convinced any of them are right
<FromGitter>
<girng> interesting. i've never used redux i'm a vanilla js guy
<FromGitter>
<tenebrousedge> have you read *You Don't Know JS* ?
<FromGitter>
<vladfaust> Once again, `pp "t".to_slice == Bytes[116] # => true`, but they are not really the same. PQ binding absolutely does not like `Bytes[116]`, but works with `"t".to_slice`. /cc @asterite
<FromGitter>
<Blacksmoke16> i mean like a lot faster
<FromGitter>
<Blacksmoke16> fixed the line count, was printing the output twice
<FromGitter>
<watzon> Not surprising. Python sucks.
<FromGitter>
<Blacksmoke16> apparently so
<FromGitter>
<girng> hey @Blacksmoke16
<FromGitter>
<Blacksmoke16> sup?
<FromGitter>
<girng> i was curious, on how to start to implement a tree system in crystal, like a web. with connected nodes. got any good starting points
<FromGitter>
<Blacksmoke16> whats the goal?
<FromGitter>
<girng> basically, allocating nodes with points. but they have to be connected
<FromGitter>
<girng> let's say, the user has 5 points to allocate
<FromGitter>
<Blacksmoke16> ah, like a skill tree?
<FromGitter>
<girng> there is a web (tree) with 5 nodes connected, but the user can't allocate that 1 node unless they have the adjacent node allocated
<FromGitter>
<Blacksmoke16> could maybe port that :P
<FromGitter>
<girng> i was curious on how to do this on the backend and store its data
<FromGitter>
<tenebrousedge> why store it?
<FromGitter>
<girng> player's skill tree data, needs to be saved in a database
<FromGitter>
<Blacksmoke16> i used that gem when i was working on my branch and bound project
<FromGitter>
<Blacksmoke16> worked quite well
<FromGitter>
<tenebrousedge> you can just store the points per skill
<FromGitter>
<Blacksmoke16> also would have to store the relationship between the skills
<FromGitter>
<tenebrousedge> yes
<FromGitter>
<Blacksmoke16> so you cant just put all your points in the later ones before skilling up the earlier ones
<FromGitter>
<Blacksmoke16> prob need a few tables to store this
<FromGitter>
<tenebrousedge> I'd have a fake root node
<FromGitter>
<girng> i was thinking of just storing the skill ids the player allocated. and then if they are try to allocate a skill id that has a dependant, they can't. but i would need to have dependents for each skill id. could be a lot
<FromGitter>
<girng> i'm going to try to just do a small one, with 5 nodes or whatnot and see what i can do
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<girng> start small
<FromGitter>
<girng> gonna look at this rubytree thingi as well
<FromGitter>
<tenebrousedge> give skills a `parent_id`, and a `children` method
<FromGitter>
<Blacksmoke16> i like that
<FromGitter>
<girng> oh i like that too
<FromGitter>
<girng> good idea
<FromGitter>
<tenebrousedge> so you can assign skill points to any skill that has less than MAX_RANKS, or any of their children
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter>
<watzon> Looks like right now it's just restructuring how Unions are represented to LLVM
<FromGitter>
<Blacksmoke16> yes, another step closer to MT
<FromGitter>
<girng> nice ;D
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<mwlang> ugh. *now* same endpoint can return either/or one object or array of objects. Trying to decide how to setup to process and deserialize that!
<FromGitter>
<mwlang> So is there the concept of "peeking" on the JSON Puller?
<FromGitter>
<Blacksmoke16> nope
<FromGitter>
<mwlang> so I can peek and see if it's a begin_array marker?
<FromGitter>
<Blacksmoke16> dont think so
<FromGitter>
<mwlang> hmm....so best bet is simply attempt to read a begin_array marker and if exception is thrown, process as single object.
<FromGitter>
<Blacksmoke16> gross
<FromGitter>
<mwlang> I don't think I've ever played so many tricks so quickly with an API implementation.
<FromGitter>
<mwlang> looking back at how I utilized Ruby-based version of what I'm rebuilding in Crystal, I pretty much just cheated.
<FromGitter>
<mwlang> I would force a response into an Array so it's always an Array with Array(JSON::parse(response.body))
<FromGitter>
<mwlang> doing simple hacks like this just doesn't seem to be in crystal's bag of tricks.
<FromGitter>
<mwlang> but I digress...time to figure out how to handle this sad puppy.
<FromGitter>
<j8r> you could also do a ugly trick, like `content.starts_with? '['` :/
<FromGitter>
<tenebrousedge> I'm told that dirty tricks ship
<FromGitter>
<j8r> or use `read_array` yes, and catch the exception.
<FromGitter>
<asterite> using pull parser, you can check the first token. The pull parser starts with the first token when you create it, so peeking is always on, at least for the next token. Based on that you could parse an array or a single object
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter>
<j8r> it reminds me to build a new jsonn pullparser not using tokens