Can like and dislike maps now for zombie survival and lava survival.

This commit is contained in:
UnknownShadow200 2016-03-20 23:54:11 +11:00
parent 90c4dedf27
commit 446560bf4f
7 changed files with 93 additions and 3 deletions

View File

@ -0,0 +1,67 @@
/*
Copyright 2015 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;
using System.Collections.Generic;
using System.Threading;
namespace MCGalaxy.Commands {
public sealed class MapLikeCmd : Command {
public override string name { get { return "maplike"; } }
public override string shortcut { get { return "like"; } }
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override bool Enabled { get { return Server.ZombieModeOn || Server.lava.active; } }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.ratedMap) { Player.SendMessage(p, "You have already liked this map."); return; }
p.level.Likes++;
p.ratedMap = true;
Player.SendMessage(p, "You have liked this map.");
}
public override void Help(Player p) {
Player.SendMessage(p, "%T/maplike");
Player.SendMessage(p, "%HIncrements the number of times this map has been liked.");
}
}
public sealed class MapDislikeCmd : Command {
public override string name { get { return "mapdislike"; } }
public override string shortcut { get { return "dislike"; } }
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override bool Enabled { get { return Server.ZombieModeOn || Server.lava.active; } }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.ratedMap) { Player.SendMessage(p, "You have already disliked this map."); return; }
p.level.Dislikes++;
p.ratedMap = true;
Player.SendMessage(p, "You have disliked this map.");
}
public override void Help(Player p) {
Player.SendMessage(p, "%T/mapdislike");
Player.SendMessage(p, "%HIncrements the number of times this map has been disliked.");
}
}
}

View File

@ -109,6 +109,8 @@ namespace MCGalaxy.Games {
double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
if (startLeft >= 0)
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
p.SendMessage("This map has &a" + CurrentLevel.Likes +
" likes %Sand &c" + CurrentLevel.Dislikes + " dislikes");
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
UpdatePlayerStatus(p);
return;

View File

@ -156,7 +156,13 @@ namespace MCGalaxy.Games {
}
void ChangeLevel(string next) {
Player[] online = PlayerInfo.Online.Items;
if (CurrentLevel != null) {
bool saveSettings = false;
foreach (Player pl in online)
saveSettings |= pl.ratedMap;
if (saveSettings) Level.SaveSettings(CurrentLevel);
CurrentLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower());
CurrentLevel.ChatLevel("Please wait while you are transfered.");
}
@ -169,8 +175,9 @@ namespace MCGalaxy.Games {
if (Server.ZombieOnlyServer)
Server.mainLevel = CurrentLevel;
Player[] online = PlayerInfo.Online.Items;
online = PlayerInfo.Online.Items;
foreach (Player pl in online) {
pl.ratedMap = false;
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
pl.SendMessage("Going to the next map!");
Command.all.Find("goto").Use(pl, next);
@ -192,6 +199,10 @@ namespace MCGalaxy.Games {
LastLevelName = "";
CurrentLevelName = "";
CurrentLevel = null;
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online)
pl.ratedMap = false;
}
void UpdatePlayerStatus(Player p) {

View File

@ -14,7 +14,7 @@
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.IO;
@ -76,6 +76,9 @@ namespace MCGalaxy.Levels.IO {
writer.WriteLine("Weather = " + level.weather);
writer.WriteLine("Texture = " + level.terrainUrl);
writer.WriteLine("TexturePack = " + level.texturePackUrl);
writer.WriteLine("Likes = " + level.Likes);
writer.WriteLine("Dislikes = " + level.Dislikes);
}
static string GetName(LevelPermission perm) {
@ -207,11 +210,15 @@ namespace MCGalaxy.Levels.IO {
case "texture":
level.terrainUrl = value; break;
case "texturepack":
level.texturePackUrl = value; break;
level.texturePackUrl = value; break;
case "buildable":
level.Buildable = bool.Parse(value); break;
case "deletable":
level.Deletable = bool.Parse(value); break;
case "likes":
level.Likes = int.Parse(value); break;
case "dislikes":
level.Dislikes = int.Parse(value); break;
}
}

View File

@ -204,6 +204,7 @@ namespace MCGalaxy
BufferedBlockSender bulkSender;
public List<C4.C4s> C4list = new List<C4.C4s>();
public int Likes, Dislikes;
public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false)
{

View File

@ -187,6 +187,7 @@
<Compile Include="Commands\Fun\CmdTeam.cs" />
<Compile Include="Commands\Fun\CmdTntWars.cs" />
<Compile Include="Commands\Fun\CmdZombieSpawn.cs" />
<Compile Include="Commands\Fun\RateMapCmds.cs" />
<Compile Include="Commands\Fun\WeaponCmd.cs" />
<Compile Include="Commands\Fun\ZombieSurvival\CmdAlive.cs" />
<Compile Include="Commands\Fun\ZombieSurvival\CmdBounties.cs" />

View File

@ -199,6 +199,7 @@ namespace MCGalaxy {
public bool flipHead = true;
public int playersInfected = 0;
internal string lastSpawnColor = "";
internal bool ratedMap = false;
//Tnt Wars
public bool PlayingTntWars = false;