Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
69a7f6d
added Dumb and DumbNoMore packet classes
Apr 27, 2014
8f0e0dc
Added SendSkillsPacket class
Apr 27, 2014
aabebef
Added a getter method to the Skill enum
Apr 27, 2014
b95662a
Added CommerceEndPacket, DisconnectPacket, LoggedPacket, NavigateTogg…
Apr 28, 2014
16a53d5
Replaced tabs with spaces.
Apr 28, 2014
18d9f3e
Updated ServerPacketsManager
May 2, 2014
28adac0
Fixed comment in Font class
May 2, 2014
3ef2533
Added WorkRequestTargetPacket
May 2, 2014
b3011a2
Added UserCommerceInitPacket
May 2, 2014
d3441e8
Added UpdateStaminaPacket
May 2, 2014
a17ac6c
Added UpdatePositionPacket
May 2, 2014
687b9df
Added UpdateManaPacket
May 2, 2014
996d767
Added UpdateHPPacket
May 2, 2014
f1f5dca
Added UpdateGoldPacket
May 2, 2014
3adb23b
Added UpdateExperiencePacket
May 2, 2014
b34fe7e
Added ShowMessageBoxPacket
May 2, 2014
4b0d7be
Added RemoveCharDialogPacket
May 2, 2014
b920443
Added ObjectDeletePacket
May 2, 2014
2266b3a
Added LoggedPacket
May 2, 2014
dcc3dd8
Added CreateFXPacket
May 2, 2014
984cd89
Added CommerceChatPacket
May 2, 2014
fa292c6
Added ChatOverHeadPacket
May 2, 2014
3ed8b0c
Added CharacterRemovePacket
May 2, 2014
1a7100a
Added CharacterMovePacket
May 2, 2014
4f4f8f4
Added CharacterForceMovePacket
May 2, 2014
9db6841
Added CharacterChangePacket
May 2, 2014
6f9ba6e
Added CharacterChangeNickNamePacket
May 2, 2014
b7ed101
Added BlockPositionPacket
May 2, 2014
7733c8d
Deleted a non-existent class import from ServerPacketsManager
May 2, 2014
016782e
Completed WalkPacket with some checks concerning moving while meditat…
May 6, 2014
43b6d94
Completed some methods to achieve character movement (haven't tested …
May 7, 2014
a9d5dd2
Fixed awful implementation from previous commit
May 8, 2014
bb43eec
Updated MapServiceImpl so it removes the user from the tile it was in…
May 8, 2014
117560c
Added some functionality so the newly created character can be logged in
May 10, 2014
1d16c5d
Added functionality for the user to be able to drop items
May 11, 2014
d1221a6
Listed all ClientPacketsManager packets
May 11, 2014
ea0309f
Possible solution to error found by junit test
May 11, 2014
12f699a
Added class to handle position update requests
May 11, 2014
04230a2
fixed typos
May 12, 2014
a60ace4
Added some fields and methods to LoggedUser and its implemented inter…
May 12, 2014
30a60af
Completed LoginExistingCharacterPacket and changed catch statement in…
May 13, 2014
e3a9ea1
aoxp-server/src/main/java/com/ao/network/packet/incoming/PickUpPacket…
May 13, 2014
a812e41
Fixed javadoc typos
May 13, 2014
0c819f6
Added a LoggedUser field to AccountImpl representing the character th…
May 13, 2014
f443542
Now LoggedUser's constructor asks for homeland and position parameter…
May 17, 2014
ff19b38
Updated DropPacket, RequestPositioUpdatePacket and WalkPacket to figu…
May 17, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions aoxp-server/src/main/java/com/ao/data/dao/ini/UserDAOIni.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.log4j.Logger;
import org.ini4j.Ini;

import com.ao.context.ApplicationContext;
import com.ao.data.dao.AccountDAO;
import com.ao.data.dao.UserCharacterDAO;
import com.ao.data.dao.exception.DAOException;
Expand All @@ -48,9 +49,11 @@
import com.ao.model.character.archetype.UserArchetype;
import com.ao.model.map.City;
import com.ao.model.map.Heading;
import com.ao.model.map.Position;
import com.ao.model.user.Account;
import com.ao.model.user.AccountImpl;
import com.ao.model.user.LoggedUser;
import com.ao.service.MapService;
import com.google.inject.Inject;
import com.google.inject.name.Named;

Expand Down Expand Up @@ -191,7 +194,11 @@ public class UserDAOIni implements AccountDAO, UserCharacterDAO {
protected static final int INITIAL_NOBLE_POINTS = 1000;

private static final Logger logger = Logger.getLogger(UserDAOIni.class);


/*---------FIXME awful workaround to be able to set char's position-----------*/
private MapService mapService = ApplicationContext.getInstance(MapService.class);
/*----------------------------------------------------------------------------*/

private String charfilesPath;

@Inject
Expand Down Expand Up @@ -285,6 +292,9 @@ public UserCharacter create(String name, Race race, Gender gender,

String positionKey = homeland.getMap() + "-" + homeland.getX() + "-" + homeland.getY();
chara.put(INIT_HEADER, POSITION_KEY, positionKey );

Position position= new Position(homeland.getX(), homeland.getY(), mapService.getMap(homeland.getMap()));

// TODO: Save last ip?

chara.put(FLAGS_HEADER, BANNED_KEY, 0);
Expand Down Expand Up @@ -380,8 +390,8 @@ public UserCharacter create(String name, Race race, Gender gender,
}

// TODO: Update this when hp, mana and hit points get updated!
return new LoggedUser(rep, race, gender, archetype.getArchetype(),
false, false, false, false, false, false, 0, 0, 0, 0,
return new LoggedUser(rep, race, gender, archetype.getArchetype(), homeland, position,
false, false, false, false, false, false, false, 0, 0, 0, 0,
100, 0, 100, 0, (byte) 1, name, "");
}

Expand Down Expand Up @@ -423,6 +433,18 @@ public UserCharacter load(String username) throws DAOException {

Archetype archetype = UserArchetype.get(Byte.parseByte(chara.get(INIT_HEADER, ARCHETYPE_KEY))).getArchetype();

int homeId= Integer.parseInt(chara.get(INIT_HEADER, HOMELAND_KEY));

City homeland= new City( homeId, mapService.getCity((byte)homeId).getX() , mapService.getCity((byte)homeId).getY());

String[] stringPos= chara.get(INIT_HEADER, POSITION_KEY).split("-");

Position position= new Position (
Byte.parseByte(stringPos[1]),
Byte.parseByte(stringPos[2]),
mapService.getMap(Integer.parseInt(stringPos[0]))
);

boolean poisoned = chara.get(FLAGS_HEADER, POISONED_KEY).equals("1");

boolean paralyzed = chara.get(FLAGS_HEADER, PARALYZED_KEY).equals("1");
Expand Down Expand Up @@ -450,9 +472,7 @@ public UserCharacter load(String username) throws DAOException {
String description = "";

// TODO : Validate character
/* UserCharacter userCharacter = new LoggedUser(reputation, race, gender, archetype, poisoned, paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, maxHitPoints, mana, hitpoints, thirstiness, hunger, lvl, username, description); */

return null;
return new LoggedUser(reputation, race, gender, archetype, homeland, position, poisoned, paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, mana, maxHitPoints, hitpoints, 100, thirstiness, 100, hunger, lvl, username, description);
}

private Ini readCharFile(String username) throws DAOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ private void loadMap(int id, WorldMap[] maps) {
logger.error("Map " + id + " loading failed!", e);
throw new RuntimeException(e);
}

try {
dataInf.close();
dataMap.close();

} catch (IOException e) {}

ByteBuffer infBuffer = ByteBuffer.wrap(bufInf);
ByteBuffer mapBuffer = ByteBuffer.wrap(bufMap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.ao.model.builder;

import java.util.Map;
Expand Down Expand Up @@ -44,6 +44,7 @@
*/
public class UserCharacterBuilder implements Builder<UserCharacter> {

//TODO we should mention what constitutes a valid name in this message.
public static final String INVALID_NAME_ERROR = "El nombre ingresado no es válido.";
public static final String INVALID_EMAIL_ERROR = "La dirección de e-mail ingresada no es válida.";

Expand All @@ -70,6 +71,7 @@ public class UserCharacterBuilder implements Builder<UserCharacter> {
protected boolean hidden = false;
protected boolean immobilized = false;
protected boolean invisible = false;
protected boolean mimetized = false;
protected byte lvl = 1;
protected boolean poisoned = false;
protected Guild guild;
Expand Down Expand Up @@ -122,6 +124,12 @@ public UserCharacterBuilder withInvisible(boolean invisible) {

return this;
}

public UserCharacterBuilder withMimetized(boolean mimetized) {
this.mimetized= mimetized;

return this;
}

public UserCharacterBuilder withDumbed(boolean dumbed) {
this.dumbed = dumbed;
Expand Down Expand Up @@ -238,7 +246,7 @@ public UserCharacterBuilder withMana(int minMana, int maxMana) {
public UserCharacterBuilder withSkills(Map<Skill, Byte> skills) throws InvalidAttributeValueException {
Preconditions.checkContentsNotNull(skills.values());

for (Skill skill : Skill.VALUES) {
for (Skill skill : Skill.values()) {
if (!skills.containsKey(skill)) {
throw new InvalidAttributeValueException();
}
Expand Down Expand Up @@ -324,8 +332,8 @@ public UserCharacter build() {
Preconditions.checkNotNull(reputation);
Preconditions.checkNotNull(position);

LoggedUser user = new LoggedUser(reputation, race, gender, archetype.getArchetype(), poisoned,
paralyzed, immobilized, invisible, dumbed, hidden, maxMana, minMana, maxHp, minHp,
LoggedUser user = new LoggedUser(reputation, race, gender, archetype.getArchetype(), homeland, position, poisoned,
paralyzed, immobilized, invisible, mimetized, dumbed, hidden, maxMana, minMana, maxHp, minHp,
maxThirstiness, minThirstiness, maxHunger, minHunger, lvl, name, description);

//TODO: Set everything!
Expand Down
4 changes: 2 additions & 2 deletions aoxp-server/src/main/java/com/ao/model/character/Gender.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public enum Gender {
/**
* Enum values.
*/
private static Gender[] values = Gender.values();
private static final Gender[] VALUES = Gender.values();

/**
* Retrieves the gender with the given index.
* @param index The gender index.
* @return The gender.
*/
public static Gender get(byte index) {
return values[index];
return VALUES[index];
}
}
78 changes: 48 additions & 30 deletions aoxp-server/src/main/java/com/ao/model/character/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,59 @@

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/

package com.ao.model.character;

/**
* Defines available skills.
*/
public enum Skill {
LUCK,
MAGIC,
STEAL,
COMBAT_TACTICS,
HAND_TO_HAND_COMBAT,
MEDITATE,
STAB,
HIDING,
SURVIVE,
LUMBER,
TRADE,
DEFENSE,
FISHING,
MINING,
WOODWORK,
IRONWORK,
LEADERSHIP,
TAME,
PROJECTILES,
WRESTLING,
SAILING;

/**
* The amount of existing skills.
*
* TODO: I don't really like this...any better alternative?
*/
public static final int AMOUNT = Skill.values().length;
public static final Skill[] VALUES = Skill.values();

//LUCK //no existe más
MAGIC,
STEALING,
COMBAT_TACTICS,
HAND_TO_HAND_COMBAT,
MEDITATION,
STABBING,
HIDING,
SURVIVAL,
LUMBER,
TRADE,
SHIELD_DEFENSE,
FISHING,
MINING,
WOODWORKING,
SMITHING,
LEADERSHIP,
TAMMING,
RANGED_COMBAT,
WRESTLING,
SAILING;

/**
* The amount of existing skills.
*
* TODO: I don't really like this...any better alternative?
*/
public static final int AMOUNT = Skill.values().length;
private static final Skill[] VALUES = Skill.values();

/**
* Maximum amount of points a character can earn for any given skill
*/
public static final int MAX_SKILL_POINT= 100;

/**
* Retrieves the skill for the given index
* @param index the index
* @return the skill at the given index
*/
public Skill get(byte index) {
//TODO: must ensure index ranges between 0 and AMOUNT(not included)
return VALUES[index];
}


}
Loading