Day2 - We haz a model and a view!

Kivy view + dictionary model

Today I put kivy frustrations aside, and set about working on the model. I'm going for a slightly weird approach, being that I want to be able to quickly implement the multiplayer part of the game. If the model can be represented 100% as a python dictionary, then it should be feasible to just pass around json strings representing the model changes. The interface for modifying the model is also reduced to specific string arguments to a function call. Here is the object I want to manipulate, and here is what I am doing with it.

To test that the model is working, I have a small unit test, and also set up my kivy client to talk to an in memory version of the model. When you drag a card and let go, it passes the request into the model. If there is an exception - which represents some change request that the model has rejected - the view simply animates the card to return to where you dragged it from. Otherwise, we make sure our widgets are updated to the positions that match the model, adding and removing cards if necessary. The animation system makes it easy to have some pleasing player feedback even though the model change was very discrete.

For this "game", on your turn, you can play a single card into the other player's hand. And then the turn automatically passes. In the above video, you can see that I have set up this simple test in a hotseat mode, where the current player the input is targeting switches when the turn switches. The white section is the current player's hand.

I am a day or so behind my original schedule, only accomplishing the first of my listed tasks :)

So I'm already preparing myself to lower my expectations. Nothing in the game yet resembles flow, and I haven't really done any game design yet (although I have an idea) So I'm going to strive to at least have the client working how I like it. If there isn't much of a game to play, so be it! I didn't realize how frustrated I would be working with kivy. I'm so much more experienced with pygame, and pretty out of practice at game programming. But I'm not sure I like how kivy is designed outside of the main use case it was designed for (apps with standard gui).

(Also I have a new cat, and she is quite a needy one so far - always wanting attention and not letting me sleep!)

To further the primary online goal, my plan for tomorrow is to have the client connect to a server that is running a single ever present game. Api something like:
/join - returns player1 or player2
/play/card_id - sends the command to play a card (which automatically ends the turn). Also returns updated state.
/getstate - returns the current game state

If it's not our turn, the client can just call /getstate once every couple seconds. If it's our turn we don't need to call it, we'll just get the state when we play the card.

(log in to comment)

Comments

awesome´╝ü