Last game was even quicker than the one before it. Felious became Dominus in just over a week. Not only was it the quickest yet it was also the fastest growing and largest. At the end of the game over 100 people were joining every day. Many people seemed excited for next game, I think the Felious/Retribution/Loki group won’t have it so easy in game 11.

The $5.75 prize pool goes to Felious who decided to roll it over to the next game. Game 11 starts with $5.75 in the prize pool

Game 11 will have some market and village…


Slava Kim recently implemented Redis in Meteor with the livedata and miniredis packages. I’ve been curious how much faster it is than Mongodb. I’m stuck on a plane so it’s either this or watch Dolphin Tale 2.

Write, read and delete 1,000 times.

On the client.

redis set: 228ms
redis get: 18
redis del: 189
redis total: 435
mongo insert: 365
mongo findOne: 3533
mongo remove: 131
mongo total: 4129

write: redis 1.62 x faster
read: redis 20.2 x faster
delete: mongo 1.4 x faster
total: redis 9.5 x faster

On the server.

redis set: 303
redis get: 128
redis del: 156
redis total: 587
mongo insert: 842…


Meteor’s check package is great for catching bugs. I put it at the top of most functions to make sure that the values passed in are correct.

function (num) {
check(num, Number);
// do important stuff with num
}

Recently I had some code that divided by zero. Infinity is a number so check(num, Number) didn’t catch it.

check(Infinity, Number); // passes
var x = 10 / 0;
check(x, Number); // passes

Meteor provides a way to create your own match pattern with Match.Where(condition). Instead of using check(num, Number) I now use my own match pattern.

validNumber = Match.Where(function(num) {…


Setting the fields when using collection.find and collection.findOne is very important. This is from the Meteor docs.

Note that when fields are specified, only changes to the included fields will trigger callbacks inobserve, observeChanges and invalidations in reactive computations using this cursor. Careful use of fields allows for more fine-grained reactivity for computations that don’t depend on an entire document.

One place where this isn’t obvious is Meteor.user().

Meteor.user()

is the same as

Meteor.users.findOne(Meteor.userId())

Meteor.user() returns the whole user object.

Template.test.helpers({
username: function() {
return Meteor.user().username;
}
});

The above works but it’s bad because anytime any attribute of Meteor.user() changes the template will re-run. The below example is a better way of doing it.

Template.test.helpers({
username: function() {
var user = Meteor.users.findOne(Meteor.userId(), {fields: {username:1}});
if (user) {
return user.username;
}
}
});

Now the template will only re-run if Meteor.user().username changes.


Here are a few things that I’ve learned while working on Dominus that I wish I had known when I started working with Meteor.

Local template variables

Meteor sessions are great but sometimes you want a local variable that you can pass between helpers, events, and created/rendered functions.

Here’s an example with sessions.

<template name=”info”>
{{text}}
</template>
Template.info.helpers({
text: function() {
return Session.get(‘text’);
}
});
Template.info.events({
‘click .button’: function() {
Session.set(‘text’, ‘bar’);
}
});
Template.info.onCreated({
Session.set(‘text’, ‘foo’);
});

This works but the session variable is global. Also if you have many instances your template then this doesn’t work. Here’s another way.

<template name=”info”>…


Updates since last game.

  • Dominus is now open source on Github. https://github.com/dan335/dominus If you would like to help improve Dominus let me know.
  • New battle system. Battles are no longer instant and can involve any number of people. Want to take down a large castle? Team up with an ally and attack together. Want to retreat? Just move your army away from the battle. Small battles are fairly quick and large battles might last a day.
  • No duplicate accounts allowed. Check the help for more info on this.
  • Large resource hexes. Some hexes produce 3 times as many resources. Be sure to protect your village if it’s near one of these.
  • Many other fixes and improvements.

Congrats to Nate for winning last game.

Dominus

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store