fix tnt wars

This commit is contained in:
UnknownShadow200 2017-01-09 12:25:35 +11:00
parent d1a1cd32ef
commit 3ba4a1a032
5 changed files with 61 additions and 49 deletions

View File

@ -73,8 +73,8 @@ namespace MCGalaxy.Blocks.Physics {
power = 3; break;
}
if (C.data.Data < threshold) {
C.data.Data++;
if ((C.data.Data >> 4) < threshold) {
C.data.Data += (1 << 4);
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
? Block.air : Block.lavastill);
return;
@ -92,25 +92,23 @@ namespace MCGalaxy.Blocks.Physics {
}
}
game.HandleKill(p, Killed);
} else if (lvl.physics < 3) {
lvl.Blockchange(x, y, z, Block.air);
} else {
if (lvl.physics < 3) {
lvl.Blockchange(x, y, z, Block.air);
} else {
if (C.data.Data < 5 && lvl.physics == 3) {
C.data.Data++;
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
? Block.air : Block.lavastill);
return;
}
MakeExplosion(lvl, x, y, z, 0);
if (C.data.Data < 5 && lvl.physics == 3) {
C.data.Data++;
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
? Block.air : Block.lavastill);
return;
}
MakeExplosion(lvl, x, y, z, 0);
}
}
static Player GetPlayer(ref PhysicsArgs args) {
if (args.Type1 != PhysicsArgs.Custom) return null;
int id = args.Value1 | args.Value2 << 8 | args.Data << 16;
int id = args.Value1 | args.Value2 << 8 | (args.Data & 0xF) << 16;
Player[] players = PlayerInfo.Online.Items;
for (int i = 0; i < players.Length; i++) {
if (players[i].SessionID == id) return players[i];
@ -131,8 +129,8 @@ namespace MCGalaxy.Blocks.Physics {
Explode(lvl, x, y, z, size + 3, rand, 3, game);
}
static void Explode(Level lvl, ushort x, ushort y, ushort z,
int size, Random rand, int prob, TntWarsGame game) {
static void Explode(Level lvl, ushort x, ushort y, ushort z,
int size, Random rand, int prob, TntWarsGame game) {
for (int xx = (x - size); xx <= (x + size ); ++xx)
for (int yy = (y - size ); yy <= (y + size); ++yy)
for (int zz = (z - size); zz <= (z + size); ++zz)

View File

@ -16,7 +16,7 @@
permissions and limitations under the Licenses.
*/
using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
using MCGalaxy.Games;
@ -254,17 +254,12 @@ namespace MCGalaxy.Commands {
case "top":
case "leaders":
if (tntwrs.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress) {
int max = 5;
if (tntwrs.PlayingPlayers() < 5) {
max = tntwrs.PlayingPlayers();
}
var pls = from pla in tntwrs.Players orderby pla.Score descending select pla; //LINQ FTW
int count = 1;
foreach (var pl in pls) {
Player.Message(p, count.ToString() + ": " + pl.p.name + " - " + pl.Score.ToString());
if (count >= max) break;
count++;
int count = Math.Min(tntwrs.PlayingPlayers(), 5);
List<TntWarsGame.player> sorted = new List<TntWarsGame.player>(tntwrs.Players);
sorted.Sort((a, b) => b.Score.CompareTo(a.Score));
for (int i = 0; i < count; i++) {
Player.Message(p, "{0}: {1} - {2}", (i + 1), sorted[i].p.name, sorted[i].Score);
Thread.Sleep(500); //Maybe, not sure (250??)
}
} else {

View File

@ -1,25 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
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;
namespace MCGalaxy
{
public enum MouseButton
{
namespace MCGalaxy {
public enum MouseButton {
Left = 0,
Right = 1,
Middle = 2
}
public enum MouseAction
{
public enum MouseAction {
Pressed = 0,
Released = 1
}
public enum TargetBlockFace
{
public enum TargetBlockFace {
AwayX = 0,
TowardsX = 1,
AwayY = 2,

View File

@ -707,19 +707,28 @@ namespace MCGalaxy.Games
}
//Other stuff
public int RedTeam()
{
return Players.Count(p => p.Red);
public int RedTeam() {
int count = 0;
foreach (player p in Players) {
if (p.Red) count++;
}
return count;
}
public int BlueTeam()
{
return Players.Count(p => p.Blue);
public int BlueTeam() {
int count = 0;
foreach (player p in Players) {
if (p.Blue) count++;
}
return count;
}
public int PlayingPlayers()
{
return Players.Count(p => !p.spec);
public int PlayingPlayers() {
int count = 0;
foreach (player p in Players) {
if (!p.spec) count++;
}
return count;
}
public static void SetTitlesAndColor(player p, bool reset = false)

View File

@ -175,7 +175,7 @@ namespace MCGalaxy {
/// <summary> Persistent ID of this user in the Players table. </summary>
public int UserID;
public const int SessionIDMask = (1 << 23) - 1;
public const int SessionIDMask = (1 << 20) - 1;
/// <summary> Temp unique ID for this session only. </summary>
public int SessionID;