Solved What is better/faster to write?

Discussion in 'Plugin Development' started by brord, Apr 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    brord

    Hey guys! I have a problem.
    In my game, there are multiple ways to win.
    Now i dont know how i detect this win.
    There are 2 ways:
    - Check for every way to win if it is true, and end the game with that
    - make a repeating scheduler form 20 ticks and check if the game has been won.

    for each option, i have a boolean ended, and a string with the reason.
    The string could be like: Timelimit exceeded: 20 minutes, Or last kill made by: [name], killed [name]

    in the first case, i have to make a lot of double code, which is really ugly.
    The second case is a bit more resource intense, but also makes the timelimit easy to make.

    What should i choose?

    Thanks in advance!
     
  2. Those 2 ways make no sense... if you can mark the game as 'won' then why would you need a repeating task checking that ? Just trigger the win when you mark it as won.
    And the other one also makes no sense on its own, would make more sense if you had them combined.

    It sounds like a deathmatch of sorts... you need to be more detailed about the game.

    The timelimit can be easily achieved with a scheduled task, if you want final seconds countdown you should make the task start at time - 10 seconds then start a repeating task that counts down or something.

    For killing, why not trigger game end at EntityDeathEvent ?

    You might want to detail the game more and preferably show some code of what you're actually checking or something, because now I'm just blindly guessing what you really need.
     
  3. Offline

    brord

    Ye i wrote it in a hurry because i had to go, and wanted to finish this question before that.
    Ill explain it a bit better now.

    The way i wrote it is that i have 1 match, which has certain triggers.
    - Time
    - damage
    - movement

    And variations on those, so certaing movements, certain ways of damage etc.
    All those triggers are different for each mode.

    So what i have is whenever any of those triggers reach a point where the match is finished (those triggers are inside Mode.class), a boolean is set to true. The match doesnt know of this untill it checks.

    Now the question is what is best todo this.

    Every trigger runs through the match, to the mode. so i could check after each trigger if the boolean is set to true.
    This will result in a lot of duplicate code, but will run a bit smoother with less triggers every tick.

    The other option is having a schgeduler check like every second if that boolean is triggered.
    Now that i explain it, the scheduler seems more efficient, but what do you guys think?

    I cannot give real code snippets due to im not allwoed to, but i hope i explained it far enough
     
  4. Offline

    Vislo

    just check in every way its more easy and quick, making a repeting task maybe can cause more lag because if the game its not running still checking so i belief the best method its check per wave but anyways if triggers are true just change the boolean to a function code because if you can change a boolean why not just execute a function that ends games.
     
  5. Offline

    devilquak

    brord

    I don't really get what you're having trouble with. In a minigame I made once, every time a certain game-event happens, i.e. a player is tagged out or a player leaves the game, I check if the player tagged was the last player left, and if the player that left made the player-count of the game too small. If either were true, then I'd call the method that would end the game. Your situation very well may be different, but we can't really help if we don't exactly know what your triggers/events are.
     
  6. Offline

    brord

    I was very vague i know, but i picked the scheduler. Thanks for the thoughts anyways :)
     
  7. Offline

    mcoder

    please mark it as solved then
     
Thread Status:
Not open for further replies.

Share This Page