I'm trying to do a turn-based game with Game Center.
My question is, can i limit the number of matches being played or created?
yes, you can. One solution would be storing the number of currently games being play into database. and checking whether it exceeds the max limit of determined or not.
I just finished developing my chess game -.-
There is a built in limit to the number of simultaneous matches (currently 30).
Suppose you know locally how many games the app is in (which is easy to find out by calling loadMatchesWithCompletionHandler).
Then, is beyond your max number of games, reject all invitations from handleInviteFromGameCenter and disable your UI for creating new games and do not create match requests.
Related
I would like to run through a modelling exercise to try and understand DDD a little better, specifically in the cases where there is a many-to-many relationship
Lets take an example of Xbox users and their achievements.
If you are not familiar this is the background:
Each game on Xbox has achievements.
User will have a list of games they own/have played and they can unlock achievements for these games.
There is a many-to-many relationship here as a user can have many games, and a game can have many users.
Without going further, there is definitely two aggregate roots here. User and game.
The game aggregate root has a list of achievements.
My confusion comes in with tracking the progress of a user for a specific game.
for instance what games they have, and what achievements they have for each game.
In a typical CRUD design it might look something like this:
How would you now model this is DDD?
User Game and User Achievement will have information regarding the progress of each.
This is a solution i currently think, but is it right?
User and game are both aggregate roots.
The progress of a game and it's individual achievements also seems to be connected and I would say that this is its own aggregate root. This is because like game and it's achievements, it potentially has a transaction boundary. When you progress on a game's achievement, this could effect the game's progress (e.g. unlocking an achievement would up the total game's gamerscore achieved.)
I keep hearing that you want to resolve many-to-many relationship, which is usually fine, but here, the relationship has its own data, and I don't think this relationship belongs to either.
You might be able to argue that you would put this on the user aggregate, but my concern is that it adds weight to that user aggregate and there is no reason for it to be there.
I don't think there is any transaction boundaries and I don't like the though of having to load all the user's games when you want to load it. Even if this was lazy loaded, I am concerned it might cause concurrency issues?
This is why I think the many to many relationship here is valid, and why a new aggregate root might be appropriate.
Also is the name user game progress even correct. Knowing the domain, what might you suggest?
Thank you, any help is massively appriciated.
What you are looking for here is Domain Events. From the Microsoft documentation:
Use domain events to explicitly implement side effects of changes
within your domain. In other words, and using DDD terminology, use
domain events to explicitly implement side effects across multiple
aggregates. Optionally, for better scalability and less impact in
database locks, use eventual consistency between aggregates within the
same domain.
The "progress of game" does not look to be an aggregate root to me. To update the "progress of game" you can raise a domain event such as "User_Moved" from your User aggregate and similar event from your Game aggregate. You can then subscribe to these events to update the game progress. Also, since Domain Events are in-memory you can achieve this within a single transaction.
I don't think you are going to find an authoritative answer to your question that is more specific than "it depends".
For instance - suppose the game was chess, and we want to award an achievement when a player has one at least once with each color. That's not going to be the responsibility of a "game" aggregate; we can see that immediately from the fact that the life cycles don't line up.
One quick way to sketch this suggests that we might have games raising "domain events" to announce wins, and then a little state machine that uses wins as inputs an announces awards, and then some report that lists all awards for a specific player id.
The state machine, and the accompanying domain logic that takes in wins and emits awards is probably an aggregate all by itself - one instance for each player.
The report - which combines this award with others for the same player... well, aside from some plumbing details that seems pretty anemic, unless you need to do something clever to show only "recent" awards, or something similar.
A good talk that explores these ideas: All Our Aggregates Are Wrong, by Mauro Servienti.
If you were to come at this initially, this "player awards" aggregate could either be its own aggregate or could be a list of awards under the player.
It certainly could be a list of awards within the player aggregate. But - assuming the analysis above is correct - the list of awards doesn't influence, and isn't influenced by, any other changes to player.
There's one list (which might be empty) for every player, and you'll want to be able to retrieve a specific player's list using the player id, but these conditions alone do not constrain us to consider the list a part of the player aggregate.
Other questions didn't really have an answer. I'm making a singleplayer game that saves to a leaderboard, and I can't have the scores be 999999999999999999999999 from Cheat Engine. How do I secure my AS3 Flash Game so that Cheat Engine does nothing?
You can't. It's unavoidable. Abandon all hope. Your game is client-side and can be tampered with. The score is sent from the client which can be intercepted and changed before it is sent to the server. Anything you do to try encode the score will fail because your SWF can be decompiled and the algorithm reverse-engineered. Even if you put yourself through hell to obfuscate your SWF and the logic used to encode a decode a score, you will not prevail. All you can do is make it not worthwhile to cheat by maximising the difficulty of sending faux scores; make the criteria of a valid score strict and hard to determine e.g. a multiple of a given number minus x.
There are ways to make it very difficult, although as others have mentioned, it will never be completely secure.
Neopets, a popular site with flash games, combats this problem by sending extra information to the server. For example, in a game you might send to the server:
Time to complete level
Number of enemies killed
Number of items collected
Score
Then on the server, check if the values make sense. If they did not kill enough enemies, reject their score. If they completed the level too quickly, reject their score.
Bind your data to something dynamically changing like time. Because cheat engine does not have such option to trace time in data. Additionally if the trainer is programmed so professionally you can combine this method and other distraction methods together like multiplying the number into another dynamic data.
I have some small flash games in facebook. How can i prevent cheating with cheat engine? My swf file sends the score to my database by php. I just dont want people to hack highscores in my flash games by using cheat engine. What is the best way to avoid these issues?
Thanks in advance..
2 methods I use are as follows
SpeedHack Watch Dog
http://www.bjoernacker.de/flash/detecting-the-cheat-engines-speedhack-in-as3/
Use this class to determine if the user is using CheatEngine to lower the frame rate
another method would to create a vault class for storing variables ina proxy, this vault will store variables within a different namespace (one that cheat engine cannot alter);
http://troyworks.com/blog/2007/08/05/introspection-in-as3-use-of-namespace/
Yes you can:
this is a really good and easy way to do it.
http://www.riawolf.com/?p=20
Short answer; you can't.
Long answer; It's a lot of work. One option is to make a server-side port of your game, make sure everything is deterministic, and send over all player actions and validate them on the server-side port (and discard any failing validations).
It depends on game , because some of them You can verify on server , checking user steps , but You can also record game and save it with scores , than replay highscores to check if games are valid .
I just add some random number to the scores ( let's say 100 ) and then substract it when I show it somewhere. After this I obfusticate the SWF file. So I would have something like : myScores = 100;. If he have 15 scores, the memory will have that 115 number and he will be looking for 15, not 115. Then I substract 100 from 115 and get the real points to be displayed. It is important to protect your swf from decompiling ( there is plenty soft that will obfusticate it ). I also run my own encrypt/decrypt function when sending to the PHP ;)
As far as I know, it's really not possible, but I just want to be sure before I'm moving to flash.
can I make an html5 game secure enough so people won't be able to change their score and other variables while playing?
thanks!
There is no "depends", the straight answer to your question is "no" and I think my fellow answerers simply muddied the waters.
You cannot trust the client. With any language, whether you're writing assembly or HTML or Flash, you cannot trust the client. No matter how much you wrap your code in obfuscation and such, it can and will be figured out (and often quicker than you might think).
This is stressed everywhere and yet people keep getting bit by it. Online games get "speedhacked" because they don't check the velocity of players, or they get item duplication because they don't verify that a player actually has an item that they're trying to do something with, or the lame little flash games get hiscore entries of 9999999 because a simple tool like Tamper Data (a Firefox add-on) is all it takes to change the score as it's sent to the server.
You can't trust the client, whether HTML5 or Flash.
If it's a single-player game, let the player cheat. That is their decision. If it's a multiplayer game, the server verifies every step of the game and anything outside of the rules is thrown out. If it's hiscores, send a replay of the game to the server and analyze it for any cheating rather than sending just a numeric score.
since your users can see all the source code this is a rather complex problem.
they can easily change any function or variable at runtime without your script ever knowing.
even if use a complicated signing function to validate the results.
and i am sorry but i don't think colins way would work either. i could just change any input to make the server do whatever i want.
maybe a constant monitoring of the score thru the server would be able to detect any impossible changes. still someone cheating in the realms of "possible" results would be uncaught.
in the end i would say u can only make it rather difficult to cheat but not impossible for someone with a little bit of skill.
don't use it for any games where u can win something by scoring the highest.
since the matter seems rather puzzling to people:
flash delivers compiled swf files, that cannot (since flash 9) be decompiled to useful.smth
so u can put a secret in there which you use to sign the score.
i.e. send the score and the md5 of score+secretkey. so the server (which also knows the key, can check it).
furthermore flash variables are not so easy to temper with (you would have to find them in ram and alter them there, which is a very complex task), while javascript vars can be easily edited using, for example, webkit developer tools
update
actually i correct myself => all swfs can be decompiled
this just leaves us with code obfuscating and "encrypting"
i guess the world is a bad place after all ;)
Depends on the way your game is coded, but if all the logic is sent to the client and only the score returned then you have no hope. Only by returning the inputs and calulating the score on the server side can you try to prevent the users submitting any score they wish.
Don't forget, by definition the user must change their score or it could never be more than 0...
One Thought!!
You may use Knockout.js to modify your score and other variables as observable properties.
The steps are:
Create ViewModal for your game
Create observable properties for all the variables (i.e score)
You need to store the score in cache so that you can access it when new score arrives.
Attach custom subscriber to these properties and write logic to check the score should be updated by a "UNIT" at a time ( by unit I mean, how you suppose to update user's score at a time). The difference between the last score and current score should not go beyond the "UNIT"
update scroe as ViewModal.Score(newScore); //this would fire an event to the subscriber of observable property.!
I'm working on a real-time space strategy game clone which at its time did not have any multiplayer option. I want to add multiplayer to it.
The gameplay itself is relatively long: about 10-15 hours of gameplay needed for complete a playthrough. This is very long and I don't want to force the players to play it uninterrupted or lose the game state due crash/power outage.
How do similar games solve this kind of problem? Save multiplayer game just like a singleplayer game?
In singleplayer mode, the player can pause and accelerate the simulation time (In pause mode, the player is still able to issue orders, build on planets, etc.).
How can this feature be translated into the multiplayer mode?
Let's assume there are more than 2 players (additional AI or human players) and one player attacks the other which switches the game into space/ground battle. These battles can be paused as well to issue orders.
What should happen with the other non-involved players? Should they wait? Should they be forced to operate only in their own kingdom?
Update: Just some details about the game.
I'm cloning this game. The clone is released as open source, therefore, its likely someone will create a cheating version. This is an issue but not that important now. I think I solve it by moving the game state and control between the players: first it runs on the first player's machine, then moves to the second etc.
I would like to put more emphasis to the third question above:
What should the other players do when two are engaged in a battle?
Battles are fought on different screen as the kingdom management screens. In single player mode, the battles automatically stop the game world and neither the player, nor the AI is able to manage its kingdom during the battle.
History shows that any feature that allows players to interact on the meta level will be abused beyond what possible good it might serve.
Perhaps it is possible to have the players agree beforehand on a "game plan", like "4x 4 hours on consecutive days" or "3x 5 hours on wednesdays".
The problem seems to be largely identical with WoW Raids: Get X players together to do something realtime-ish, which is longer than typical game time on one day, with multiple sessions within one week. This of course involves a leader role, hot seats, saving to a spot etc. This is hard enough to do, and all these people are working together!
If someone sees they´re off to a bad start on the first 3 hours, how can you expect them to come back to suffer 12 more hours? Well, have the quitter lose? This means collusion, you win one for me, I win one for you. (2 players win one each in 6 hours - much better than playing it through)
All of this has been thoroughly tried. If there is a way to break the game by cheating, people will do that. Especially when it is PvP.
Successful multiplayer games either have engagements that are short enough (less than one evening), or that are clearly interruptible (stages reached), or arent realtime. Sadly, I see no way around this malady.
Long story short: I dont think a 15hr PvP RTS even makes sense. For a single player, it means being better than a fixed quality computer opponent. You try, you learn, you beat it eventually. PvP, it means if you are 1% less efficient in the first 5 mins, against an equally skilled opponent, you will definitely lose in the end.
A Games value is measured in pleasure per hour.
Work pausing into the gameplay. Give each player a pause at the beginning of the game, and then force them to buy pauses with in game currency.
Limit the number of consecutive pauses, a pause by one player would prevent pausing by another player for 10 minutes unless that other player pays for it at a penalized price.
Also limit the length of each pause, and allow other players to pay money to undo the pause.
I dont think you can do it that way.
You cant have a multiplayer rts that allows pausing that allows issuing orders.
Players would pause, issue orders, wait to see what the other players do, instantly pause again as soon as it wants to change anything and issue new orders.
This would not be a RTS it would be a CST (Chaotic Turnbased Stategy) game.
I've never seen a game solve this problem. You might allow players to vote to postpone the game and resume it at a later time (i.e., a save feature), which could make the long game sessions bearable, but I don't think pausing will work in multiplayer.
Civ VI is turn based although in multiplayer it plays out in real time (you get a certain number of minutes/seconds per turn). So it faces the same challenge--4+ players doing a game that lasts forever. It solves the problem by allowing players to save the game and then come back to it later. When you go to create a server you have the option of starting a new game or starting off with one of your saves. If you start with a save, then each player chooses whatever civilization they had before and things pick up where they left off
You may want to consider a 'phase-based' system. Each phase may be considered as a single pause. Players are allowed to issue instructions during each phase and then have the instructions carried out. Instructions that are issued in the first phase will only be executed in the second phase by the units.
You might consider giving players that aren't at the keyboard the ability to create reactions to certain situations. Since these are preset reactions, they won't be as good as an actual player on standby, but it also allows the game to continue without players being available.
I'm working on a game right now which allows you to program reactions for your characters, so that if you engage another player in the game, without you being available, then your characters still respond.
I'm using simple macros to help players map out their characters reactions. I'm making some very generic and others very complex... for example
If [player1]
Is [attacked]
And Health [<30%]
Action [DefensiveStance]
That way - even though not all players are available the game can continue to run. Conversely, depending on how much effort a player puts into his "AFK" scripting, then the better his team will perform.
Of course, it's still in progress - we will see later on just how well it turns out :)