2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
import com.massivecraft.factions.zcore.persist.json.JSONBoard;
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-11-06 01:36:47 +01:00
|
|
|
import java.util.ArrayList;
|
2015-04-26 07:02:30 +02:00
|
|
|
import java.util.Set;
|
2014-11-06 01:36:47 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract class Board {
|
|
|
|
protected static Board instance = getBoardImpl();
|
2014-11-06 01:36:47 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
//----------------------------------------------//
|
|
|
|
// Get and Set
|
|
|
|
//----------------------------------------------//
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract String getIdAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
private static Board getBoardImpl() {
|
|
|
|
switch (Conf.backEnd) {
|
|
|
|
case JSON:
|
|
|
|
return new JSONBoard();
|
|
|
|
}
|
|
|
|
return null;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public static Board getInstance() {
|
|
|
|
return instance;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract Faction getFactionAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void setIdAt(String id, FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void setFactionAt(Faction faction, FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void removeAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-04-26 07:02:30 +02:00
|
|
|
public abstract Set<FLocation> getAllClaims(String factionId);
|
|
|
|
|
|
|
|
public abstract Set<FLocation> getAllClaims(Faction faction);
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void clearOwnershipAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void unclaimAll(String factionId);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
|
|
|
// Simpler: Is there any nearby coord with a faction other than the faction here?
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract boolean isBorderLocation(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
// Is this coord connected to any coord claimed by the specified faction?
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract boolean isConnectedLocation(FLocation flocation, Faction faction);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-01-29 16:39:56 +01:00
|
|
|
public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//----------------------------------------------//
|
|
|
|
// Cleaner. Remove orphaned foreign keys
|
|
|
|
//----------------------------------------------//
|
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract void clean();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//----------------------------------------------//
|
|
|
|
// Coord count
|
|
|
|
//----------------------------------------------//
|
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract int getFactionCoordCount(String factionId);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract int getFactionCoordCount(Faction faction);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract int getFactionCoordCountInWorld(Faction faction, String worldName);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//----------------------------------------------//
|
|
|
|
// Map generation
|
|
|
|
//----------------------------------------------//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The map is relative to a coord and a faction north is in the direction of decreasing x east is in the direction
|
|
|
|
* of decreasing z
|
|
|
|
*/
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract boolean forceSave();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract boolean load();
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|