View Javadoc

1   package cz.cuni.amis.pogamut.ut3.agent.module.sensor;
2   
3   import java.util.logging.Logger;
4   
5   import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
6   import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
7   import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Game;
8   import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Items;
9   import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
10  import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
11  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.*;
12  import cz.cuni.amis.pogamut.ut3.communication.messages.UT3ItemType;
13  
14  public class UT3Items extends Items {	
15  	
16  	public UT3Items(UT2004Bot bot, AgentInfo agentInfo, Game game,
17  			Weaponry weaponry, Logger log) {
18  		super(bot, agentInfo, game, weaponry, log);
19  	}
20  
21  	public boolean isPickable(Item item) {
22      	// health
23          ItemType itemType = item.getType();
24              
25      	if ( itemType == UT3ItemType.MEDIUM_HEALTH && agentInfo.isHealthy() ) {
26      		return false;
27      	}
28      	if ( itemType == UT3ItemType.SUPER_HEALTH_PACK && agentInfo.isSuperHealthy() ) {
29      		return false;
30      	}
31      	if ( itemType == UT3ItemType.HEALTH_VIAL && agentInfo.isSuperHealthy() ) {
32      		return false;
33      	}
34      	
35      	//TODO - armor!
36      	/*if ( itemType == UT3ItemType.ARMOR_HELMET && agentInfo.hasHighArmor() ) {
37      		return false;
38      	}*/
39  
40      	
41      	// weapons
42      	if ( itemType.getCategory() == UT3ItemType.Category.WEAPON ) {
43      		if ( game.getGameInfo().isWeaponStay() ) {
44      			return !weaponry.hasWeapon(itemType);
45      		} else {
46                      
47      			/*return weaponry.getPrimaryWeaponAmmo( itemType ) < weaponry.getWeaponDescriptor( itemType ).getPriMaxAmount()
48      				   ||
49      				   weaponry.getSecondaryWeaponAmmo( itemType ) < weaponry.getWeaponDescriptor( item.getType() ).getSecMaxAmount();*/
50      		}
51      	}
52      	
53      	//TODO - ammo
54      	/*if ( itemType.getCategory() == UT3ItemType.Category.AMMO && weaponry.getAmmo(itemType) >= weaponry.getMaxAmmo(itemType) ) {
55      		return false;
56      	}*/
57      	
58      	
59      	// ultra damage
60      	if ( itemType == UT3ItemType.U_DAMAGE_PACK && agentInfo.hasUDamage() ) {
61      		return false;
62      	}
63  
64      	return true;
65  	}
66  	/**
67  	 * Returns how fast are the items respawning based on their item type (in real seconds according to {@link System#currentTimeMillis()}.
68  	 * @param UT3ItemType
69  	 * @return
70  	 */
71  	public double getItemRespawnTime(ItemType ut3ItemType) {
72  		if (ut3ItemType.equals(UT3ItemType.U_DAMAGE_PACK) || ut3ItemType.equals(UT3ItemType.REDEEMER)) {
73  			return 3 * 28.5;
74  		} else
75  		if (ut3ItemType.equals(UT3ItemType.SUPER_HEALTH_PACK) || ut3ItemType.equals(UT3ItemType.ARMOR_SHIELD_BELT)) {
76  			return 2 * 28.5;
77  		} else {
78  			return 28.5;
79  		}
80  	}
81  	
82  	
83  
84  	
85  }