GameKit allow us to end a turn with a timeout for the next participant in the match. However, I couldn't find a way to set a timeout for the first participant for its first move. Is there anyway to do that?
EDIT
It started to make sense to me why Apple would leave this out from GameKit. When you just join a GKTurnBasedMatch you will always be in turn so there's no need for a timeout considering that it was added to avoid frustration on players while waiting too long for their turn. The thing is that my use case for a timeout is different. I'm designing a tournament and a timeout means that you lost the match, no matter it's the first turn or not. So I always need to have the ability to timeout the current turn. I'm afraid I'll need to implement this on the server which just sucks.
Might be a little late on this one, but Game Center TBM timeouts don't work like that.
When you call endTurnWithNextParticipants you must provide a list of players that will receive the turn if the previous one times out. If you want a player to lose the game when he/she times out, you must implement this e.g. on the client of the next player that receives the turn, Apple serves won't do this for you.
Based on what you're aiming for, I think the best implementation would be to check for the time the latest turn was played, or the match creation time in case it's the first turn, compare it to the current system date and time and programmatically end the match if time is over.
Like you point out, as player1 on turn1, there aren't any other players yet, so I suspect that's why GC doesn't give us an interface to set the timeout for player1.
How about setting an NSTimer to the desired timeout, and then ending the turn when it fires?
If you're looking at a long timeout, say a few days, where the user might leave and then rejoin after the timeout, you could calculate the desired deadline by adding the timeout interval to the match start time, and store that in NSUserDefaults. On each game startup, check if the deadline has passed, and end the turn when appropriate.
Related
I am looking to poll Unity inputs over the last several frames and use that data to interpret the user's button presses. From what I've tested however, it feels like polling at the application's 60 FPS framerate leads to some very fast inputs getting missed.
Simple example, user tries to go to Forward from Down:
frame 1 - user is holding Down
frame 1.5 - user taps Forward, but hasn't released Down yet
frame 2 - user lets go of Down and has reached Forward fully
In my current set up, using unity's framerate update, frame 1.5 where the user has both Down and Forward held is missed entirely. Is there a way to run a separate update, that runs at a faster rate than the regular Unity MonoBehaviour Update function? Or would a different solution be needed, such as querying via events(iirc that's an option, but I may be misremembering)?
I don't believe it's possible to decouple polling frequency from frame rate in legacy input system, however in new input system there is a pollingFrequency property that allows you define the frequency in Hertz. It uses a background thread to poll the data. You also need to subscribe to an input action change and record your values there to finally consume them in update method.
sorry my english. Im not native speaker.
Hi all, i have a dude about stops in Pine-script.
I'm tring to make a specific trail stop in my strategy script.
I want to make a for loop to evaluate all candless from open strategy date until today.
Has pine-script any variable which contains open position date or number of days or similar thing ?
thank you very much.
There is no variable that I know of that records the date of entries, but since it's your strategy, you should know when it's entering/exiting trades, so you should be able to save the time when those events occur.
Also, rather than waiting for a number of bars to elapse and go back over them with a for loop, it will be much more efficient for you to start tracking whatever info you need from the moment your condition triggers. For most needs, this should allow you to forego using a for loop.
I was just reading this thread: Strategy with sample code
And noticed that it has some work with trailing stop in it. Basically, you should be able to find some pine scripts that work with trailing stops and tailor it to your needs.
I am interested in capturing the time a particular material handler(AGV in my case) spends at a particular node before it is released. Is there a way to do so?
This works in general, since I don't know anything about your model (there are many other ways depending on what you are doing):
Create a variable and make it equal to time when your AGV arrives to the node:
timeWhenArrivesToNode=time();
Create another variable and make it equal to the amount of time it spent in that node... This code should be executed at the moment when the AGV leaves the node:
timesWhenItIsReleased=time()-timeWhenArrivesToNode;
Of course the answer will have the time units of your model.
I want to show a different option to the user in workflow through input node, depending upon whether the user has modified the record or not.
Problem is if I would use a condition node with custom class to detect whether object has been modified by some person or not in between the workflow process then as soon as the person clicks on route workflow the save is automatically called and isModified() flag gets false, How do I get in condition node whether some person has modified the record or not.
I have to show different options to the user if he has modified and different option on routing workflow if he have not modified.
Sounds to me like you need to enable eAudit on the object and then to check whether eauditusername on the most recent audit record for that object bears the userid of the current user.
It's a little hokey and tempts fate, but if your condition node is early in the workflow's route when this button is pressed, you could try and check to see if the changedate on the object (assuming you are working with one of the many objects that has one) is within the last 5 seconds. There is a gap where the record could be routed twice within a few seconds, but the gap is fairly hard to hit. There is also a gap where if the system slows down at that point and takes more than 5 seconds to get to and run your condition, then it would appear to be not modified. You can play with the delay to find a sweet spot of the fewest false positives and negatives.
I'm starting to work on an app similar to tamagotchi (virtual pet kind of stuff) in the Corona SDK. I got absolutely stuck and am out of ideas on how to get one part.
How can the game character, lets say "pet" change its status, e.g. become hungry or die while the game is inactive? Or maybe its possible to make the changes as the player enters the game the next time, maybe to bind it to the global time (still no idea of how to do it)?
I would appreciate any help.
The simplest I can think is to keep all relevant data in a file. The first datum would be a time stamp of the last time the game was turned inactive.
Every time the game is first activated it reads the file along with the time stamp. After a specific time length has passed the pet becomes hungry, tired, etc. If an extraordinary long time has passed the pet dies.
You can go further by putting a time stamp next to each datum like "last fed", "last watered", etc. and then you can make individual attributes expire at different times, including death by boredom by keeping the global "last active" time and if a long time has passed without running the game the pet dies.
I actually created an application like this. I created a number of states in a enum and then in a checkMoodState method I hardcoded the values that decided the state of the mood.
e.g.
timeSinceLastPlay
timeSinceLastFeed
or whatever.
Either write the dates to a plist for each variable you want to track and on each check or store them in NSUserDefaults(one function to write them all, one to load them all), subtract the current time from it. You will be left with a negative number, and you can just get its absolute value.
You decide whenever you want to check the last time since whatever it is you are checking, e.g. feeding. Create an NSTimer with the duration of the time between checks and in the method called by the timer, you do you checks and update the mood as you need.