Minifixio / pocketmine-1vs1-plugin

1vs1 pocketmine plugin for Minecraft Pocket Edition
Apache License 2.0
18 stars 38 forks source link

Random map in 1vs1 #36

Open RocoWayne opened 8 years ago

RocoWayne commented 8 years ago

Create a system with random map so the users dont fight every time in the fist map that you add. I think that is a simple feature

robske110 commented 8 years ago

I do have that on my server! (You can test it on robskebueba.no-ip.biz:3114)

robske110 commented 8 years ago

But as @Minifixio doesn't accept PRs i can't help you

RocoWayne commented 8 years ago

can you share your phar maybe?

robske110 commented 8 years ago

I can compile it for you

RocoWayne commented 8 years ago

oh, that will be great :D

XiangZhao969 commented 8 years ago

can you share it @robske110

Landy005 commented 8 years ago

@robske110 Would you be able to show me the changes you made? (show commit)

Thanks

robske110 commented 8 years ago

Ok, here it is:

robske110 commented 8 years ago
    private function launchNewRounds(){

        // Check that there is at least 2 players in the queue
        if(count($this->queue) < 2){
            Server::getInstance()->getLogger()->debug("There is not enough players to start a duel : " . count($this->queue));
            return;
        }

        // Check if there is any arena free (not active)
        Server::getInstance()->getLogger()->debug("Check ".  count($this->arenas) . " arenas");

        $freeArena = NULL;
        $freeArenaCount = 0;
        foreach ($this->arenas as $arena){
            if(!$arena->active){
                $freeArenaCount++;
                $freeArena[$freeArenaCount] = $arena;
            }
        }

        if($freeArena == NULL){
            Server::getInstance()->getLogger()->debug("[1vs1] - No free arena found");
            return;
        }

        //Randomize
        $freeArenas = count($freeArena);
        var_dump($freeArenas);
        $finalArena = mt_rand(1, $freeArenas);
        var_dump($finalArena);
        $freeArenafinal = $freeArena[$finalArena];

        // Send the players into the arena (and remove them from queues)
        $roundPlayers = array();
        array_push($roundPlayers, array_shift($this->queue), array_shift($this->queue));
        Server::getInstance()->getLogger()->debug("[1vs1] - Starting duel : " . $roundPlayers[0]->getName() . " vs " . $roundPlayers[1]->getName());
        $freeArenafinal->startRound($roundPlayers);
    }
robske110 commented 8 years ago

Just replace the function launchNewRounds with this in Arena Manager

Landy005 commented 8 years ago

ily

robske110 commented 8 years ago

What?

Landy005 commented 8 years ago

'i love you' :p and how do you edit the amount of blocks that you spawn from each other? 5 isn't really enough.

robske110 commented 8 years ago

Somewhere is an constant It is quite obvious search it lol

robske110 commented 8 years ago

In arena.php there is player_offset...

Landy005 commented 8 years ago

i changed that, gave me an error lol rip

Landy005 commented 8 years ago

const PLAYER_1_OFFSET_X = 5; const PLAYER_2_OFFSET_X = -5;

gives error if i took it for 30 and idk why cus it's normally possible

ghost commented 8 years ago

Robske. Can you upload yout code ffor random map.

ghost commented 8 years ago

Ive got it

XiangZhao969 commented 8 years ago

Can anyone share the phar with random arena? I tried robske's but it crashed

robske110 commented 8 years ago

You cannot use the github version, its broken

XiangZhao969 commented 8 years ago

Can you share the working phar? I used your code above and it crashed too

robske110 commented 8 years ago

I do not have an phar

robske110 commented 8 years ago

Wait, I'll make an fork (stay tuned, could take some time)

XiangZhao969 commented 8 years ago

Nice

Landy005 commented 8 years ago

i have a version with all the changes of the other guys who forked + with mine, youreturn in creative mode though :P fork mine and make a phar out of it here: http://pmt.mcpe.me/ but i haven't tested if it works but i hope it does :D

XiangZhao969 commented 8 years ago

@robske110

robske110 commented 8 years ago

What

ghost commented 8 years ago

Any news in TeamVsTeam ?

Landy005 commented 8 years ago

^ :D also adding points for economic? killrate doest work for some reason while this plugin is running a match..