Max world claim count

This commit is contained in:
BuildTools
2016-04-19 17:57:28 +02:00
committed by Olof Larsson
parent 7fc22db45a
commit 32db800fe1
6 changed files with 122 additions and 8 deletions

View File

@@ -276,6 +276,25 @@ public class Board extends Entity<Board> implements BoardInterface
return ret;
}
// CLAIMED
@Override
public boolean hasClaimed(Faction faction)
{
return this.hasClaimed(faction.getId());
}
@Override
public boolean hasClaimed(String factionId)
{
for (TerritoryAccess ta : this.map.values())
{
if ( ! ta.getHostFactionId().equals(factionId)) continue;
return true;
}
return false;
}
// NEARBY DETECTION
// Is this coord NOT completely surrounded by coords claimed by the same faction?
@@ -302,7 +321,7 @@ public class Board extends Entity<Board> implements BoardInterface
return false;
}
@Override
public boolean isAnyBorderPs(Set<PS> pss)
{

View File

@@ -14,6 +14,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.MStore;
@@ -240,6 +241,25 @@ public class BoardColl extends Coll<Board> implements BoardInterface
return ret;
}
// COUNT
@Override
public boolean hasClaimed(Faction faction)
{
return this.hasClaimed(faction.getId());
}
@Override
public boolean hasClaimed(String factionId)
{
for (Board board : this.getAll())
{
if ( ! board.hasClaimed(factionId)) continue;
return true;
}
return false;
}
// NEARBY DETECTION
@Override
@@ -291,6 +311,28 @@ public class BoardColl extends Coll<Board> implements BoardInterface
return board.getMap(observer, centerPs, inDegrees, width, height);
}
// -------------------------------------------- //
// WORLDS
// -------------------------------------------- //
public Set<String> getClaimedWorlds(Faction faction)
{
return getClaimedWorlds(faction.getId());
}
public Set<String> getClaimedWorlds(String factionId)
{
Set<String> ret = new MassiveSet<>();
for (Board board : this.getAll())
{
if ( ! board.hasClaimed(factionId)) continue;
ret.add(board.getId());
}
return ret;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //

View File

@@ -33,6 +33,10 @@ public interface BoardInterface
public int getCount(String factionId);
public Map<Faction, Integer> getFactionToCount();
// CLAIMED
public boolean hasClaimed(Faction faction);
public boolean hasClaimed(String factionId);
// NEARBY DETECTION
public boolean isBorderPs(PS ps);
public boolean isAnyBorderPs(Set<PS> pss);

View File

@@ -995,6 +995,15 @@ public class Faction extends Entity<Faction> implements EconomyParticipator, Nam
return this.getLandCount() > this.getPowerRounded();
}
// -------------------------------------------- //
// WORLDS
// -------------------------------------------- //
public Set<String> getClaimedWorlds()
{
return BoardColl.get().getClaimedWorlds(this);
}
// -------------------------------------------- //
// FOREIGN KEY: MPLAYER
// -------------------------------------------- //

View File

@@ -235,6 +235,9 @@ public class MConf extends Entity<MConf>
// 0 means there isn't.
public int claimedLandsMax = 0;
// The max amount of worlds in which a player can have claims in.
public int claimedWorldsMax = -1;
// -------------------------------------------- //
// PROTECTION
// -------------------------------------------- //