Move zombie game block handing into IGame.HandlesManualChange implementation.

This commit is contained in:
UnknownShadow200 2016-01-25 00:36:33 +11:00
parent 21d527e741
commit 644c1552f7
5 changed files with 68 additions and 40 deletions

View File

@ -17,10 +17,13 @@
*/
using System;
namespace MCGalaxy.Games {
namespace MCGalaxy {
public abstract class IGame {
public virtual bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
byte action, byte tile, byte b) {
return false;
}
}
}

56
Games/ZombieGame.Game.cs Normal file
View File

@ -0,0 +1,56 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
namespace MCGalaxy {
public sealed partial class ZombieGame : IGame {
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
byte action, byte tile, byte b) {
if (action == 1 && Server.noPillaring && !p.referee) {
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
p.blocksStacked++;
} else {
p.blocksStacked = 0;
}
if (p.blocksStacked == 2 ) {
p.SendMessage("You are pillaring! Stop before you get kicked!");
}
if (p.blocksStacked == 4 ) {
Command.all.Find("kick").Use(null, p.name + " No pillaring allowed!");
return true;
}
}
p.lastXblock = x; p.lastYblock = y; p.lastZblock = z;
if (action == 1 || (action == 0 && p.painting)) {
if (p.level.name != Server.zombie.currentLevelName || p.referee) return false;
if (p.blockCount == 0 ) {
p.SendMessage("You have no blocks left.");
p.RevertBlock(x, y, z); return true;
}
p.blockCount--;
if ((p.blockCount % 10) == 0 || (p.blockCount >= 0 && p.blockCount <= 10)) {
p.SendMessage("Blocks Left: " + c.maroon + p.blockCount);
}
}
return false;
}
}
}

View File

@ -26,7 +26,7 @@ using System.Timers;
namespace MCGalaxy
{
public sealed class ZombieGame
public sealed partial class ZombieGame
{
public int amountOfRounds = 0;
public int limitRounds = 0;

View File

@ -401,6 +401,7 @@
<Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" />
<Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" />
<Compile Include="Games\IGame.cs" />
<Compile Include="Games\ZombieGame.Game.cs" />
<Compile Include="Levels\IO\ConvertDAT.cs" />
<Compile Include="Levels\IO\LvlFile.cs" />
<Compile Include="Levels\IO\LvlProperties.cs" />

View File

@ -1072,23 +1072,6 @@ namespace MCGalaxy {
extType = type;
type = Block.custom_block;
}
if ( action == 1 && Server.ZombieModeOn && Server.noPillaring ) {
if ( !referee ) {
if ( lastYblock == y - 1 && lastXblock == x && lastZblock == z ) {
blocksStacked++;
} else {
blocksStacked = 0;
}
if ( blocksStacked == 2 ) {
SendMessage("You are pillaring! Stop before you get kicked!");
}
if ( blocksStacked == 4 ) {
Command.all.Find("kick").Use(null, name + " No pillaring allowed!");
}
}
}
lastXblock = x; lastYblock = y; lastZblock = z;
ManualChange(x, y, z, action, type, extType);
} catch ( Exception e ) {
// Don't ya just love it when the server tattles?
@ -1120,23 +1103,8 @@ namespace MCGalaxy {
RevertBlock(x, y, z); return;
}
if ( Server.ZombieModeOn && ( action == 1 || ( action == 0 && this.painting ) ) ) {
if ( Server.zombie != null && this.level.name == Server.zombie.currentLevelName ) {
if ( blockCount == 0 ) {
if ( !referee ) {
SendMessage("You have no blocks left.");
RevertBlock(x, y, z); return;
}
}
if ( !referee ) {
blockCount--;
if ( blockCount == 40 || blockCount == 30 || blockCount == 20 || blockCount <= 10 && blockCount >= 0 ) {
SendMessage("Blocks Left: " + c.maroon + blockCount + Server.DefaultColor);
}
}
}
}
if (Server.ZombieModeOn && Server.zombie != null
&& Server.zombie.HandlesManualChange(this, x, y, z, action, type, b)) return;
if ( Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this) ) {
SendMessage("You are out of the round, and cannot build.");