mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-01 01:23:12 -04:00
Move more zombie game related code into IGame implementation, also refactor the code somewhat.
This commit is contained in:
parent
644c1552f7
commit
52fa4f53ca
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCGalaxy
|
Copyright 2011 MCGalaxy
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
public sealed class CmdVote : Command
|
public sealed class CmdVote : Command
|
||||||
@ -26,38 +26,25 @@ namespace MCGalaxy.Commands
|
|||||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
public CmdVote() { }
|
public CmdVote() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message) {
|
||||||
{
|
if (message == "") { Help(p); return; }
|
||||||
if (message != "")
|
|
||||||
{
|
if (!Server.voting) {
|
||||||
if (!Server.voting)
|
Server.voting = true;
|
||||||
{
|
Server.NoVotes = 0; Server.YesVotes = 0;
|
||||||
string temp = message.Substring(0, 1) == "%" ? "" : Server.DefaultColor;
|
Player.GlobalMessage(c.green + " VOTE: %S" + message + "%S(" + c.green + "Yes" + " %S/ " + c.red + "No" + "%S)");
|
||||||
Server.voting = true;
|
System.Threading.Thread.Sleep(15000);
|
||||||
Server.NoVotes = 0;
|
|
||||||
Server.YesVotes = 0;
|
Server.voting = false;
|
||||||
Player.GlobalMessage(" " + c.green + "VOTE: " + temp + message + "(" + c.green + "Yes " + Server.DefaultColor + "/" + c.red + "No" + Server.DefaultColor + ")");
|
Player.GlobalMessage("The votes are in! " + c.green + "Y: " + Server.YesVotes + c.red + " N: " + Server.NoVotes);
|
||||||
System.Threading.Thread.Sleep(15000);
|
Player.players.ForEach(pl => pl.voted = false);
|
||||||
Server.voting = false;
|
} else{
|
||||||
Player.GlobalMessage("The vote is in! " + c.green + "Y: " + Server.YesVotes + c.red + " N: " + Server.NoVotes);
|
p.SendMessage("A vote is in progress!");
|
||||||
Player.players.ForEach(delegate(Player winners)
|
|
||||||
{
|
|
||||||
winners.voted = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.SendMessage("A vote is in progress!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Help(p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void Help(Player p)
|
|
||||||
{
|
public override void Help(Player p) {
|
||||||
p.SendMessage("/vote [message] - Obviously starts a vote!");
|
p.SendMessage("/vote [message] - Starts a vote for 15 seconds.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,5 +25,17 @@ namespace MCGalaxy {
|
|||||||
byte action, byte tile, byte b) {
|
byte action, byte tile, byte b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool HandlesChatMessage(Player p, string message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void PlayerJoinedServer(Player p) { }
|
||||||
|
|
||||||
|
public virtual void PlayerLeftServer(Player p) { }
|
||||||
|
|
||||||
|
public virtual void PlayerJoinedGame(Player p) { }
|
||||||
|
|
||||||
|
public virtual void PlayerLeftGame(Player p) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
Copyright 2010 MCLawl Team -
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Created by Snowl (David D.) and Cazzar (Cayde D.)
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
|
||||||
not use this file except in compliance with the Licenses. You may
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
obtain a copy of the Licenses at
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
not use this file except in compliance with the Licenses. You may
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
obtain a copy of the Licenses at
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
http://www.osedu.org/licenses/ECL-2.0
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
or implied. See the Licenses for the specific language governing
|
|
||||||
permissions and limitations under the Licenses.
|
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;
|
using System;
|
||||||
|
|
||||||
@ -18,8 +22,8 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public sealed partial class ZombieGame : IGame {
|
public sealed partial class ZombieGame : IGame {
|
||||||
|
|
||||||
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||||
byte action, byte tile, byte b) {
|
byte action, byte tile, byte b) {
|
||||||
if (action == 1 && Server.noPillaring && !p.referee) {
|
if (action == 1 && Server.noPillaring && !p.referee) {
|
||||||
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
||||||
p.blocksStacked++;
|
p.blocksStacked++;
|
||||||
@ -52,5 +56,23 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandlesChatMessage(Player p, string message) {
|
||||||
|
message = message.ToLower();
|
||||||
|
if (Player.CheckVote(message, p, "1", "one", ref Server.Level1Vote) ||
|
||||||
|
Player.CheckVote(message, p, "2", "two", ref Server.Level2Vote) ||
|
||||||
|
Player.CheckVote(message, p, "3", "three", ref Server.Level3Vote))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!p.voice) {
|
||||||
|
p.SendMessage("Chat moderation is on while voting is on!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PlayerLeftServer(Player p) {
|
||||||
|
InfectedPlayerDC();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ namespace MCGalaxy
|
|||||||
if (initialChangeLevel)
|
if (initialChangeLevel)
|
||||||
{
|
{
|
||||||
Server.votingforlevel = true;
|
Server.votingforlevel = true;
|
||||||
Player.GlobalMessage(" " + c.black + "Level Vote: " + Server.DefaultColor + selectedLevel1 + ", " + selectedLevel2 + " or random " + "(" + c.lime + "1" + Server.DefaultColor + "/" + c.red + "2" + Server.DefaultColor + "/" + c.blue + "3" + Server.DefaultColor + ")");
|
Player.GlobalMessage(" " + c.black + "Level Vote: " + Server.DefaultColor + selectedLevel1 + ", " + selectedLevel2 + " or random " + "(" + c.lime + "1%S/" + c.red + "2%S/" + c.blue + "3%S)");
|
||||||
System.Threading.Thread.Sleep(15000);
|
System.Threading.Thread.Sleep(15000);
|
||||||
Server.votingforlevel = false;
|
Server.votingforlevel = false;
|
||||||
}
|
}
|
||||||
|
@ -2177,82 +2177,25 @@ return;
|
|||||||
SendMessage(from, "Your vote for &5" + message.ToLower().Capitalize() + Server.DefaultColor + " has been placed. Thanks!");
|
SendMessage(from, "Your vote for &5" + message.ToLower().Capitalize() + Server.DefaultColor + " has been placed. Thanks!");
|
||||||
Server.lava.map.ChatLevelOps(from.name + " voted for &5" + message.ToLower().Capitalize() + Server.DefaultColor + ".");
|
Server.lava.map.ChatLevelOps(from.name + " voted for &5" + message.ToLower().Capitalize() + Server.DefaultColor + ".");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SendMessage(from, "&cYou already voted!");
|
SendMessage(from, "&cYou already voted!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Server.voting ) {
|
if (Server.voting) {
|
||||||
if ( message.ToLower() == "yes" || message.ToLower() == "ye" || message.ToLower() == "y" ) {
|
string test = message.ToLower();
|
||||||
if ( !from.voted ) {
|
if (CheckVote(test, from, "y", "yes", ref Server.YesVotes) ||
|
||||||
Server.YesVotes++;
|
CheckVote(test, from, "n", "no", ref Server.NoVotes)) return;
|
||||||
SendMessage(from, c.red + "Thanks For Voting!");
|
|
||||||
from.voted = true;
|
if (!from.voice && (test == "y" || test == "n" || test == "yes" || test == "no")) {
|
||||||
return;
|
from.SendMessage("Chat moderation is on while voting is on!"); return;
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( message.ToLower() == "no" || message.ToLower() == "n" ) {
|
|
||||||
if ( !from.voted ) {
|
|
||||||
Server.NoVotes++;
|
|
||||||
SendMessage(from, c.red + "Thanks For Voting!");
|
|
||||||
from.voted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Server.votingforlevel ) {
|
if (Server.votingforlevel && Server.zombie.HandlesChatMessage(from, message))
|
||||||
if ( message.ToLower() == "1" || message.ToLower() == "one" ) {
|
return;
|
||||||
if ( !from.voted ) {
|
|
||||||
Server.Level1Vote++;
|
|
||||||
SendMessage(from, c.red + "Thanks For Voting!");
|
|
||||||
from.voted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( message.ToLower() == "2" || message.ToLower() == "two" ) {
|
|
||||||
if ( !from.voted ) {
|
|
||||||
Server.Level2Vote++;
|
|
||||||
SendMessage(from, c.red + "Thanks For Voting!");
|
|
||||||
from.voted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( message.ToLower() == "3" || message.ToLower() == "random" || message.ToLower() == "rand" ) {
|
|
||||||
if ( !from.voted ) {
|
|
||||||
Server.Level3Vote++;
|
|
||||||
SendMessage(from, c.red + "Thanks For Voting!");
|
|
||||||
from.voted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( !from.voice ) {
|
|
||||||
from.SendMessage("Chat moderation is on while voting is on!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Last50Chat.Count() == 50)
|
if (Last50Chat.Count() == 50)
|
||||||
Last50Chat.RemoveAt(0);
|
Last50Chat.RemoveAt(0);
|
||||||
var chatmessage = new ChatMessage();
|
var chatmessage = new ChatMessage();
|
||||||
@ -2564,7 +2507,7 @@ level.Unload();
|
|||||||
Server.s.Log(ip + " disconnected.");
|
Server.s.Log(ip + " disconnected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.zombie.InfectedPlayerDC();
|
Server.zombie.PlayerLeftServer(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( Exception e ) { Server.ErrorLog(e); }
|
catch ( Exception e ) { Server.ErrorLog(e); }
|
||||||
@ -2913,5 +2856,15 @@ Next: continue;
|
|||||||
}
|
}
|
||||||
return replacement + "/" + replacement2;
|
return replacement + "/" + replacement2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static bool CheckVote(string message, Player p, string a, string b, ref int totalVotes) {
|
||||||
|
if (!p.voted && (message == a || message == b)) {
|
||||||
|
totalVotes++;
|
||||||
|
p.SendMessage(c.red + "Thanks for voting!");
|
||||||
|
p.voted = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user