project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Room.java
changeset 7358 57a508884052
parent 7352 641f11cdd319
equal deleted inserted replaced
7355:5673e95ef647 7358:57a508884052
     1 package org.hedgewars.hedgeroid.netplay;
     1 package org.hedgewars.hedgeroid.netplay;
     2 
       
     3 import java.util.Comparator;
       
     4 
     2 
     5 import org.hedgewars.hedgeroid.R;
     3 import org.hedgewars.hedgeroid.R;
     6 
     4 
     7 import android.content.res.Resources;
     5 import android.content.res.Resources;
     8 
     6 
     9 public class Room {
     7 public class Room {
    10 	public static final String MAP_REGULAR = "+rnd+";
     8 	public static final String MAP_REGULAR = "+rnd+";
    11 	public static final String MAP_MAZE = "+maze+";
     9 	public static final String MAP_MAZE = "+maze+";
    12 	public static final String MAP_DRAWN = "+drawn+";
    10 	public static final String MAP_DRAWN = "+drawn+";
    13 	public static final Comparator<Room> ID_COMPARATOR = new ByIdComparator();
       
    14 	
    11 	
    15 	public final String name, map, scheme, weapons, owner;
    12 	public final String name, map, scheme, weapons, owner;
    16 	public final int playerCount, teamCount;
    13 	public final int playerCount, teamCount;
    17 	public final boolean inProgress;
    14 	public final boolean inProgress;
    18 	public final long id;	// for ListView
       
    19 	
    15 	
    20 	public Room(String name, String map, String scheme, String weapons,
    16 	public Room(String name, String map, String scheme, String weapons,
    21 			String owner, int playerCount, int teamCount, boolean inProgress, long id) {
    17 			String owner, int playerCount, int teamCount, boolean inProgress) {
    22 		this.name = name;
    18 		this.name = name;
    23 		this.map = map;
    19 		this.map = map;
    24 		this.scheme = scheme;
    20 		this.scheme = scheme;
    25 		this.weapons = weapons;
    21 		this.weapons = weapons;
    26 		this.owner = owner;
    22 		this.owner = owner;
    27 		this.playerCount = playerCount;
    23 		this.playerCount = playerCount;
    28 		this.teamCount = teamCount;
    24 		this.teamCount = teamCount;
    29 		this.inProgress = inProgress;
    25 		this.inProgress = inProgress;
    30 		this.id = id;
       
    31 	}
    26 	}
    32 
    27 
    33 	public static String formatMapName(Resources res, String map) {
    28 	public static String formatMapName(Resources res, String map) {
    34 		if(map.charAt(0)=='+') {
    29 		if(map.charAt(0)=='+') {
    35 			if(map.equals(MAP_REGULAR)) {
    30 			if(map.equals(MAP_REGULAR)) {
    40 				return res.getString(R.string.map_drawn);
    35 				return res.getString(R.string.map_drawn);
    41 			}
    36 			}
    42 		}
    37 		}
    43 		return map;
    38 		return map;
    44 	}
    39 	}
    45 	
       
    46 	private static final class ByIdComparator implements Comparator<Room> {
       
    47 		public int compare(Room lhs, Room rhs) {
       
    48 			return lhs.id<rhs.id ? -1 : lhs.id>rhs.id ? 1 : 0;
       
    49 		}
       
    50 	}
       
    51 }
    40 }