Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex

This commit is contained in:
Chiss 2013-10-19 16:52:27 +11:00
commit 7cec55713c
34 changed files with 278 additions and 219 deletions

View File

@ -138,7 +138,6 @@ public class CoreClientManager implements Listener
token = gson.fromJson(response, ClientToken.class); token = gson.fromJson(response, ClientToken.class);
client.SetAccountId(token.AccountId); client.SetAccountId(token.AccountId);
client.SetFilterChat(token.FilterChat);
client.SetRank(Rank.valueOf(token.Rank)); client.SetRank(Rank.valueOf(token.Rank));
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));

View File

@ -8,5 +8,4 @@ public class ClientToken
public int EconomyBalance; public int EconomyBalance;
public AccountToken AccountToken; public AccountToken AccountToken;
public Boolean FilterChat;
} }

View File

@ -0,0 +1,141 @@
package mineplex.core.antihack;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Map.Entry;
import org.bukkit.entity.Player;
public class AntiHackRepository
{
private AntiHack _plugin;
private String _serverName;
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/Mineplex";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256) NOT NULL, hackType VARCHAR(256) NOT NULL, playerName VARCHAR(256) NOT NULL, hackCount INT, updated LONG, PRIMARY KEY (id), UNIQUE KEY serverName_hackType_playerName (serverName, hackType, playerName));";
private static String UPDATE_PLAYER_OFFENSES = "REPLACE INTO AntiHack (serverName, playerName, hackType, hackCount, updated) VALUES (?, ?, ?, ?, now());";
public AntiHackRepository(AntiHack plugin, String serverName)
{
_plugin = plugin;
_serverName = serverName;
}
public void initialize()
{
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
public void saveOffenses()
{
new Thread(new Runnable()
{
public void run()
{
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_OFFENSES);
synchronized (_plugin.getOffensesSynch())
{
for (Player offender : _plugin.getOffenses().keySet())
{
for (Entry<String, Integer> hackEntry : _plugin.getOffenses().get(offender).entrySet())
{
preparedStatement.setString(1, _serverName);
preparedStatement.setString(2, offender.getName());
preparedStatement.setString(3, hackEntry.getKey());
preparedStatement.setInt(4, hackEntry.getValue());
preparedStatement.addBatch();
}
}
_plugin.getOffenses().clear();
}
preparedStatement.executeBatch();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
}).start();
}
}

View File

@ -0,0 +1,16 @@
package mineplex.core.chat;
public class ChatClient
{
private boolean _filterChat = false;
public void SetFilterChat(boolean filterChat)
{
_filterChat = filterChat;
}
public boolean GetFilterChat()
{
return _filterChat;
}
}

View File

@ -0,0 +1,21 @@
package mineplex.core.chat.command;
import org.bukkit.entity.Player;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
public class FilterChatCommand extends CommandBase<Chat>
{
public FilterChatCommand(Chat plugin)
{
super(plugin, Rank.ALL, "filter");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.Get(caller).ToggleFilterChat();
}
}

View File

@ -8,7 +8,6 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.DonationRepository;
import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.donation.repository.token.DonorTokenWrapper;
import mineplex.core.donation.repository.token.PlayerUpdateToken;
import mineplex.core.server.util.TransactionResponse; import mineplex.core.server.util.TransactionResponse;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson; import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
@ -130,9 +129,11 @@ public class DonationManager extends MiniPlugin
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int greenGems) public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int greenGems)
{ {
_repository.PlayerUpdate(new Callback<PlayerUpdateToken>() _repository.PlayerUpdate(new Callback<Boolean>()
{ {
public void run(PlayerUpdateToken token) public void run(Boolean success)
{
if (success)
{ {
Donor donor = Get(name); Donor donor = Get(name);
@ -144,25 +145,7 @@ public class DonationManager extends MiniPlugin
if (callback != null) if (callback != null)
callback.run(true); callback.run(true);
} }
}
}, caller, name, greenGems); }, caller, name, greenGems);
} }
public void RewardGems(final Callback<Boolean> callback, final String name, final int greenGems)
{
_repository.PlayerUpdate(new Callback<PlayerUpdateToken>()
{
public void run(PlayerUpdateToken token)
{
Donor donor = Get(name);
if (donor != null)
{
donor.AddGems(greenGems);
}
if (callback != null)
callback.run(true);
}
}, name, greenGems);
}
} }

View File

@ -1,7 +1,7 @@
package mineplex.core.donation.repository; package mineplex.core.donation.repository;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.donation.repository.token.PlayerUpdateToken; import mineplex.core.donation.repository.token.GemRewardToken;
import mineplex.core.donation.repository.token.PurchaseToken; import mineplex.core.donation.repository.token.PurchaseToken;
import mineplex.core.donation.repository.token.UnknownPurchaseToken; import mineplex.core.donation.repository.token.UnknownPurchaseToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.AsyncJsonWebCall;
@ -37,20 +37,12 @@ public class DonationRepository
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, callback, token); new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, callback, token);
} }
public void PlayerUpdate(Callback<PlayerUpdateToken> callback, String name, int greenGems) public void PlayerUpdate(Callback<Boolean> callback, String giver, String name, int greenGems)
{ {
PlayerUpdateToken token = new PlayerUpdateToken(); GemRewardToken token = new GemRewardToken();
token.Name = name;
token.Gems = greenGems;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PlayerUpdate").Execute(PlayerUpdateToken.class, callback, token);
}
public void PlayerUpdate(Callback<PlayerUpdateToken> callback, String giver, String name, int greenGems)
{
PlayerUpdateToken token = new PlayerUpdateToken();
token.Source = giver; token.Source = giver;
token.Name = name; token.Name = name;
token.Gems = greenGems; token.Amount = greenGems;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PlayerUpdate").Execute(PlayerUpdateToken.class, callback, token); new AsyncJsonWebCall(_webAddress + "PlayerAccount/GemReward").Execute(Boolean.class, callback, token);
} }
} }

View File

@ -1,9 +1,8 @@
package mineplex.core.donation.repository.token; package mineplex.core.donation.repository.token;
public class PlayerUpdateToken public class GemRewardToken
{ {
public String Source; public String Source;
public String Name; public String Name;
public int Gems; public int Amount;
public boolean FilterChat;
} }

View File

@ -147,38 +147,6 @@ public class Punish extends MiniPlugin
event.disallow(Result.KICK_BANNED, reason); event.disallow(Result.KICK_BANNED, reason);
} }
} }
/*
for (String alias : client.Acc().GetAliasIP())
{
if (Clients().Get(alias).Ban().IsBanned())
{
String reason = C.consoleHead + "Alias Banned" +
C.consoleFill + " - " +
C.consoleBody + client.Ban().GetBan().RemainingString() +
C.consoleFill + " - " +
C.consoleBody + client.Ban().Reason();
event.disallow(Result.KICK_BANNED, reason);
return;
}
}
for (String alias : client.Acc().GetAliasMAC())
{
if (Clients().Get(alias).Ban().IsBanned())
{
String reason = C.consoleHead + "Alias Banned" +
C.consoleFill + " - " +
C.consoleBody + client.Ban().GetBan().RemainingString() +
C.consoleFill + " - " +
C.consoleBody + client.Ban().Reason();
event.disallow(Result.KICK_BANNED, reason);
return;
}
}
*/
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View File

@ -5,7 +5,6 @@ import java.util.List;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
public class PunishClient public class PunishClient
{ {
private NautHashMap<Category, List<Punishment>> _punishments; private NautHashMap<Category, List<Punishment>> _punishments;

View File

@ -258,7 +258,7 @@ public class ParkourManager extends MiniPlugin
//Sound //Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
} }
}, player.getName(), data.Gems); }, "Parkour " + data.Name, player.getName(), data.Gems);
} }
} }
} }

View File

@ -138,7 +138,7 @@ public class TutorialManager extends MiniPlugin
//Sound //Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
} }
}, player.getName(), tut.GetGems()); }, "Tutorial " + tut.GetTutName(), player.getName(), tut.GetGems());
} }
} }
} }

View File

@ -1,9 +0,0 @@
package nautilus.minecraft.core.account;
public class GameClass
{
public String Name;
public String Description;
public double Price;
public boolean Free;
}

View File

@ -1,8 +0,0 @@
package nautilus.minecraft.core.account;
public class GameSalesPackage
{
public int GameSalesPackageId;
public int Credits;
public int Points;
}

View File

@ -120,10 +120,10 @@ public class GameGemManager implements Listener
//Give Gems //Give Gems
if (give) if (give)
GiveGems(player, game.GetPlayerGems().remove(player), game.GemMultiplier); GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier);
} }
public void GiveGems(Player player, HashMap<String,GemData> gems, double gameMult) public void GiveGems(Game game, Player player, HashMap<String,GemData> gems, double gameMult)
{ {
if (gems == null) if (gems == null)
return; return;
@ -141,7 +141,7 @@ public class GameGemManager implements Listener
total = (int) (total * gameMult); total = (int) (total * gameMult);
Manager.GetDonation().RewardGems(null, player.getName(), total); Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), total);
} }
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give) public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.donation.repository.token.PlayerUpdateToken; import mineplex.core.donation.repository.token.GemRewardToken;
import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.remotecall.JsonWebCall;
import nautilus.game.dominate.stats.DominateGameStatsToken; import nautilus.game.dominate.stats.DominateGameStatsToken;
@ -18,13 +18,13 @@ public class DominateRepository
_webServerAdddress = webServerAddress; _webServerAdddress = webServerAddress;
} }
public void SaveGameStats(final Callback<List<PlayerUpdateToken>> callback, final DominateGameStatsToken dominationGameStats) public void SaveGameStats(final Callback<List<GemRewardToken>> callback, final DominateGameStatsToken dominationGameStats)
{ {
Thread asyncThread = new Thread(new Runnable() Thread asyncThread = new Thread(new Runnable()
{ {
public void run() public void run()
{ {
List<PlayerUpdateToken> tokenList = new JsonWebCall(_webServerAdddress + "Dominate/UploadStats").Execute(new TypeToken<List<PlayerUpdateToken>>(){}.getType(), dominationGameStats); List<GemRewardToken> tokenList = new JsonWebCall(_webServerAdddress + "Dominate/UploadStats").Execute(new TypeToken<List<GemRewardToken>>(){}.getType(), dominationGameStats);
callback.run(tokenList); callback.run(tokenList);
} }
}); });

View File

@ -8,7 +8,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor; import mineplex.core.donation.Donor;
import mineplex.core.donation.repository.token.PlayerUpdateToken; import mineplex.core.donation.repository.token.GemRewardToken;
import nautilus.game.core.engine.TeamType; import nautilus.game.core.engine.TeamType;
import nautilus.game.core.events.GamePlayerAfkEvent; import nautilus.game.core.events.GamePlayerAfkEvent;
import nautilus.game.core.events.team.TeamGameFinishedEvent; import nautilus.game.core.events.team.TeamGameFinishedEvent;
@ -89,11 +89,11 @@ public class DominateStatsReporter implements Listener
gameStats.PlayerStats.add(playerStats); gameStats.PlayerStats.add(playerStats);
} }
_repository.SaveGameStats(new Callback<List<PlayerUpdateToken>>() _repository.SaveGameStats(new Callback<List<GemRewardToken>>()
{ {
public void run(List<PlayerUpdateToken> tokenList) public void run(List<GemRewardToken> tokenList)
{ {
for (PlayerUpdateToken token : tokenList) for (GemRewardToken token : tokenList)
{ {
try try
{ {
@ -102,9 +102,9 @@ public class DominateStatsReporter implements Listener
if (player != null && player.isOnline()) if (player != null && player.isOnline())
{ {
donor.AddGems(token.Gems); donor.AddGems(token.Amount);
player.sendMessage(F.main("Dominate", "You earned " + ChatColor.YELLOW + token.Gems + C.cGray + " gems for playing!")); player.sendMessage(F.main("Dominate", "You earned " + ChatColor.YELLOW + token.Amount + C.cGray + " gems for playing!"));
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -62,7 +62,7 @@ public class GPResult
if (_gp.GetTrack().GetPositions().size() > 0 && sortedScores.size() > 0) if (_gp.GetTrack().GetPositions().size() > 0 && sortedScores.size() > 0)
{ {
_first = sortedScores.get(0); _first = sortedScores.get(0);
manager.RewardGems(null, _first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer); manager.RewardGems(null, "Earned Minekart", _first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer);
} }
buffer += 2; buffer += 2;
@ -70,7 +70,7 @@ public class GPResult
if (_gp.GetTrack().GetPositions().size() > 1 && sortedScores.size() > 1) if (_gp.GetTrack().GetPositions().size() > 1 && sortedScores.size() > 1)
{ {
_second = sortedScores.get(1); _second = sortedScores.get(1);
manager.RewardGems(null, _second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer); manager.RewardGems(null, "Earned Minekart", _second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer);
} }
buffer += 2; buffer += 2;
@ -78,14 +78,14 @@ public class GPResult
if (_gp.GetTrack().GetPositions().size() > 2 && sortedScores.size() > 2) if (_gp.GetTrack().GetPositions().size() > 2 && sortedScores.size() > 2)
{ {
_third = sortedScores.get(2); _third = sortedScores.get(2);
manager.RewardGems(null, _third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer); manager.RewardGems(null, "Earned Minekart", _third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer);
} }
buffer += 2; buffer += 2;
for (int i = 3; i < sortedScores.size(); i++) for (int i = 3; i < sortedScores.size(); i++)
{ {
manager.RewardGems(null, sortedScores.get(i).GetDriver().getName(), buffer); manager.RewardGems(null, "Earned Minekart", sortedScores.get(i).GetDriver().getName(), buffer);
} }
_fireworkLocations = new ArrayList<Location>(5); _fireworkLocations = new ArrayList<Location>(5);

View File

@ -69,7 +69,7 @@
<Compile Include="Model\Account\MacAddress.cs" /> <Compile Include="Model\Account\MacAddress.cs" />
<Compile Include="Model\Account\RemovedPunishment.cs" /> <Compile Include="Model\Account\RemovedPunishment.cs" />
<Compile Include="Model\Sales\AccountTransaction.cs" /> <Compile Include="Model\Sales\AccountTransaction.cs" />
<Compile Include="Model\Sales\AccountGemTransaction.cs" /> <Compile Include="Model\Sales\GemTransaction.cs" />
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigGameStatsToken.cs" /> <Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigGameStatsToken.cs" />
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" /> <Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" />
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominatePlayerStatsToken.cs" /> <Compile Include="Model\Server\GameServer\Dominate\Stats\DominatePlayerStatsToken.cs" />
@ -145,7 +145,7 @@
<Compile Include="Tokens\Client\LoginRequestToken.cs" /> <Compile Include="Tokens\Client\LoginRequestToken.cs" />
<Compile Include="Tokens\Client\PetChangeToken.cs" /> <Compile Include="Tokens\Client\PetChangeToken.cs" />
<Compile Include="Tokens\Client\PetToken.cs" /> <Compile Include="Tokens\Client\PetToken.cs" />
<Compile Include="Tokens\Client\PlayerUpdateToken.cs" /> <Compile Include="Tokens\Client\GemRewardToken.cs" />
<Compile Include="Tokens\Client\SlotToken.cs" /> <Compile Include="Tokens\Client\SlotToken.cs" />
<Compile Include="Tokens\Client\RemovePunishmentToken.cs" /> <Compile Include="Tokens\Client\RemovePunishmentToken.cs" />
<Compile Include="Tokens\Client\UpdateTaskToken.cs" /> <Compile Include="Tokens\Client\UpdateTaskToken.cs" />

View File

@ -4,7 +4,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Sales; using Sales;
using Server;
using Server.GameServer; using Server.GameServer;
using Server.GameServer.CaptureThePig.Stats; using Server.GameServer.CaptureThePig.Stats;
using Server.GameServer.Dominate.Stats; using Server.GameServer.Dominate.Stats;
@ -62,5 +61,6 @@
public List<CaptureThePigPlayerStats> CaptureThePigStats { get; set; } public List<CaptureThePigPlayerStats> CaptureThePigStats { get; set; }
public List<AccountTransaction> AccountTransactions { get; set; } public List<AccountTransaction> AccountTransactions { get; set; }
public List<GemTransaction> GemTransactions { get; set; }
} }
} }

View File

@ -1,15 +0,0 @@
namespace LOC.Core.Model.Server
{
public class AccountGemTransaction
{
public int AccountGemTransactionId { get; set; }
public string Source { get; set; }
public string Reason { get; set; }
public bool Earned { get; set; }
public Account.Account Account { get; set; }
}
}

View File

@ -0,0 +1,13 @@
namespace LOC.Core.Model.Sales
{
public class GemTransaction
{
public int GemTransactionId { get; set; }
public Account.Account Account { get; set; }
public string Source { get; set; }
public int Amount { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace LOC.Core.Tokens.Client
{
public class GemRewardToken
{
public string Name { get; set; }
public string Source { get; set; }
public int Amount { get; set; }
}
}

View File

@ -1,11 +0,0 @@
namespace LOC.Core.Tokens.Client
{
public class PlayerUpdateToken
{
public string Name { get; set; }
public int Gems { get; set; }
public bool FilterChat { get; set; }
}
}

View File

@ -148,15 +148,35 @@
} }
} }
public Account UpdateAccount(Account account) public bool GemReward(GemRewardToken token)
{ {
using (var repository = _repositoryFactory.CreateRepository()) using (var repository = _repositoryFactory.CreateRepository())
{ {
var account = repository.Where<Account>(x => x.Name == token.Name).FirstOrDefault();
account.LoadNavigationProperties(repository.Context);
if (account == null)
return false;
account.Gems += token.Amount;
var gemTransaction = new GemTransaction
{
Source = token.Source,
Account = account,
Amount = token.Amount
};
if (account.GemTransactions == null)
account.GemTransactions = new List<GemTransaction>();
account.GemTransactions.Add(gemTransaction);
repository.Edit(account); repository.Edit(account);
repository.CommitChanges(); repository.CommitChanges();
} }
return account; return true;
} }
public void AddTask(UpdateTaskToken token) public void AddTask(UpdateTaskToken token)

View File

@ -14,9 +14,9 @@
{ {
public CaptureThePigAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { } public CaptureThePigAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { }
public List<PlayerUpdateToken> UploadStats(CaptureThePigGameStatsToken token) public List<GemRewardToken> UploadStats(CaptureThePigGameStatsToken token)
{ {
var updateTokenList = new List<PlayerUpdateToken>(); var updateTokenList = new List<GemRewardToken>();
var pointsPerMinute = Math.Min(2 / (token.Length / 60000), 2); var pointsPerMinute = Math.Min(2 / (token.Length / 60000), 2);
using (var repository = RepositoryFactory.CreateRepository()) using (var repository = RepositoryFactory.CreateRepository())
@ -28,7 +28,7 @@
UpdateStatsForAccount(repository, account, earnedPoints, playerStats); UpdateStatsForAccount(repository, account, earnedPoints, playerStats);
updateTokenList.Add(new PlayerUpdateToken { Name = account.Name, Gems = earnedPoints }); updateTokenList.Add(new GemRewardToken { Name = account.Name, Amount = earnedPoints });
} }
repository.CommitChanges(); repository.CommitChanges();

View File

@ -15,9 +15,9 @@
{ {
public DominateAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { } public DominateAdministrator(INautilusRepositoryFactory repositoryFactory) : base(repositoryFactory) { }
public List<PlayerUpdateToken> UploadStats(DominateGameStatsToken token) public List<GemRewardToken> UploadStats(DominateGameStatsToken token)
{ {
var updateTokenList = new List<PlayerUpdateToken>(); var updateTokenList = new List<GemRewardToken>();
var timeDifference = token.Duration - ((long)new TimeSpan(DateTime.Now.ToUniversalTime().Ticks - new DateTime(1970, 1, 1).Ticks).TotalMilliseconds) - new TimeSpan(0, 15, 0).TotalMilliseconds; var timeDifference = token.Duration - ((long)new TimeSpan(DateTime.Now.ToUniversalTime().Ticks - new DateTime(1970, 1, 1).Ticks).TotalMilliseconds) - new TimeSpan(0, 15, 0).TotalMilliseconds;
var direction = timeDifference / Math.Abs(timeDifference); var direction = timeDifference / Math.Abs(timeDifference);
var pointsAccordingToDuration = Math.Min(Math.Abs(timeDifference), 5) * direction + 35; var pointsAccordingToDuration = Math.Min(Math.Abs(timeDifference), 5) * direction + 35;
@ -31,7 +31,7 @@
UpdateStatsForAccount(repository, account, earnedPoints, playerStats); UpdateStatsForAccount(repository, account, earnedPoints, playerStats);
updateTokenList.Add(new PlayerUpdateToken { Name = account.Name, Gems = earnedPoints }); updateTokenList.Add(new GemRewardToken { Name = account.Name, Amount = earnedPoints });
} }
repository.CommitChanges(); repository.CommitChanges();

View File

@ -16,7 +16,7 @@
Account GetAccountByName(string name); Account GetAccountByName(string name);
Account GetAccountById(int id); Account GetAccountById(int id);
Account CreateAccount(string name); Account CreateAccount(string name);
Account UpdateAccount(Account account); bool GemReward(GemRewardToken token);
void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee); void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee);
Account Login(LoginRequestToken loginToken); Account Login(LoginRequestToken loginToken);
void Logout(string name); void Logout(string name);

View File

@ -6,6 +6,6 @@
public interface ICaptureThePigAdministrator : IPvpAdministrator public interface ICaptureThePigAdministrator : IPvpAdministrator
{ {
List<PlayerUpdateToken> UploadStats(CaptureThePigGameStatsToken token); List<GemRewardToken> UploadStats(CaptureThePigGameStatsToken token);
} }
} }

View File

@ -6,6 +6,6 @@
public interface IDominateAdministrator : IPvpAdministrator public interface IDominateAdministrator : IPvpAdministrator
{ {
List<PlayerUpdateToken> UploadStats(DominateGameStatsToken token); List<GemRewardToken> UploadStats(DominateGameStatsToken token);
} }
} }

View File

@ -83,17 +83,6 @@ namespace LOC.Website.Web.Areas.Manage.Controllers
return View(account); return View(account);
} }
[HttpPost]
public ActionResult Edit(Account account)
{
if (ModelState.IsValid)
{
_accountAdministrator.UpdateAccount(account);
return RedirectToAction("Index");
}
return View(account);
}
public ActionResult Delete(int id) public ActionResult Delete(int id)
{ {
Account account = context.Accounts.Single(x => x.AccountId == id); Account account = context.Accounts.Single(x => x.AccountId == id);

View File

@ -135,15 +135,9 @@
} }
[HttpPost] [HttpPost]
public ActionResult PlayerUpdate(PlayerUpdateToken token) public ActionResult GemReward(GemRewardToken token)
{ {
var account = _accountAdministrator.GetAccountByName(token.Name); var json = JsonConvert.SerializeObject(_accountAdministrator.GemReward(token));
account.Gems += token.Gems;
account.FilterChat = token.FilterChat;
_accountAdministrator.UpdateAccount(account);
var json = JsonConvert.SerializeObject(token);
return Content(json, "application/json"); return Content(json, "application/json");
} }
@ -154,43 +148,6 @@
return Content(json, "application/json"); return Content(json, "application/json");
} }
[HttpPost]
public ActionResult PlayerVoted(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var newPoints = 0;
if (account != null)
{
if (DateTime.Now.Subtract(account.LastVote) < TimeSpan.FromDays(2))
{
account.VoteModifier = Math.Min(account.VoteModifier + 1, 2);
}
else
{
account.VoteModifier = 0;
}
newPoints = 30 + (10*account.VoteModifier);
account.Gems += newPoints;
account.LastVote = DateTime.Now;
_accountAdministrator.UpdateAccount(account);
}
var token = new PlayerUpdateToken { Name = name, Gems = newPoints };
var json = JsonConvert.SerializeObject(token);
return Content(json, "application/json");
}
[HttpPost]
public void RecordDeathStat(DeathStatToken token)
{
}
[HttpPost] [HttpPost]
public ActionResult GetPunishClient(string name) public ActionResult GetPunishClient(string name)
{ {

View File

@ -22,10 +22,5 @@
{ {
return _accountAdministrator.GetAccountByName(name); return _accountAdministrator.GetAccountByName(name);
} }
public Account UpdateAccount(Account account)
{
return _accountAdministrator.UpdateAccount(account);
}
} }
} }

Binary file not shown.