Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

adding missing features #146

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/Engine/CharEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ define(function( require )
Network.setPing(function(){
Network.sendPacket(ping);
});

Session.Playing = false;
//Session.hasCart = false;


UIManager.getComponent('WinLoading').remove();

Expand Down
1 change: 1 addition & 0 deletions src/Engine/LoginEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ define(function( require )
*/
var _loginID = '';

var _rophservers = [];

/**
* Init Game
Expand Down
19 changes: 18 additions & 1 deletion src/Engine/MapEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ define(function( require )
var BasicInfo = require('UI/Components/BasicInfo/BasicInfo');
var WinStats = require('UI/Components/WinStats/WinStats');
var Inventory = require('UI/Components/Inventory/Inventory');
var CartItems = require('UI/Components/CartItems/CartItems');
var Vending = require('UI/Components/Vending/Vending');
var ChangeCart = require('UI/Components/ChangeCart/ChangeCart');
var ShortCut = require('UI/Components/ShortCut/ShortCut');
var Equipment = require('UI/Components/Equipment/Equipment');
var StatusIcons = require('UI/Components/StatusIcons/StatusIcons');
Expand Down Expand Up @@ -109,14 +112,21 @@ define(function( require )
Session.Character.GID = fp.readLong();
}
});


var hbt = new PACKET.CZ.HBT();

var is_sec_hbt = Configs.get('sec_HBT', null);

// Ping
var ping = new PACKET.CZ.REQUEST_TIME();
var startTick = Date.now();
Network.setPing(function(){
if(is_sec_hbt)Network.sendPacket(hbt);
ping.clientTime = Date.now() - startTick;
Network.sendPacket(ping);
});

Session.Playing = true;
}, true);

// Do not hook multiple time
Expand Down Expand Up @@ -165,6 +175,9 @@ define(function( require )
MiniMap.prepare();
Escape.prepare();
Inventory.prepare();
CartItems.prepare();
Vending.prepare();
ChangeCart.prepare();
Equipment.prepare();
ShortCut.prepare();
ChatRoomCreate.prepare();
Expand Down Expand Up @@ -199,6 +212,7 @@ define(function( require )
function onPong( pkt )
{
//pkt.time

}


Expand Down Expand Up @@ -288,6 +302,9 @@ define(function( require )
BasicInfo.append();
Escape.append();
Inventory.append();
CartItems.append();
Vending.append();
ChangeCart.append();
Equipment.append();
StatusIcons.append();
ShortCut.append();
Expand Down
1 change: 1 addition & 0 deletions src/Engine/MapEngine/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ define(function( require )

// Show cart (in future)
case StatusConst.ON_PUSH_CART:
//console.log("Entity on PushCart");
if (entity === Session.Entity) {
Session.hasCart = pkt.state;
}
Expand Down
62 changes: 62 additions & 0 deletions src/Engine/MapEngine/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define(function( require )
var ItemObtain = require('UI/Components/ItemObtain/ItemObtain');
var ItemSelection = require('UI/Components/ItemSelection/ItemSelection');
var Inventory = require('UI/Components/Inventory/Inventory');
var CartItems = require('UI/Components/CartItems/CartItems');
var Equipment = require('UI/Components/Equipment/Equipment');


Expand Down Expand Up @@ -338,7 +339,62 @@ define(function( require )

debugger;
}

/**
* Generic function to add items to cart
*
* @param {object} pkt - PACKET.ZC.CART_EQUIPMENT_ITEMLIST3
*/
function onCartSetList( pkt )
{
CartItems.setItems( pkt.itemInfo || pkt.ItemInfo );
}

/**
* Generic function to set cart info
*
* @param {object} pkt - PACKET.ZC.NOTIFY_CARTITEM_COUNTINFO
*/
function onCartSetInfo( pkt )
{
CartItems.setCartInfo( pkt.curCount, pkt.maxCount, pkt.curWeight, pkt.maxWeight );
}

function onCartRemoveItem( pkt )
{
CartItems.removeItem( pkt.index, pkt.count);
}

CartItems.reqRemoveItem = function ReqRemoveItem( index, count )
{
if (count <= 0) {
return;
}

var pkt = new PACKET.CZ.MOVE_ITEM_FROM_CART_TO_BODY();
pkt.index = index;
pkt.count = count;
Network.sendPacket( pkt );
};

Inventory.reqMoveItemToCart = function reqMoveItemToCart( index, count )
{
if (count <= 0) {
return;
}

var pkt = new PACKET.CZ.MOVE_ITEM_FROM_BODY_TO_CART();
pkt.index = index;
pkt.count = count;
Network.sendPacket( pkt );
};


function onCartItemAdded( pkt )
{
CartItems.addItem(pkt);
}


/**
* Initialize
Expand All @@ -358,6 +414,9 @@ define(function( require )
Network.hookPacket( PACKET.ZC.NORMAL_ITEMLIST2, onInventorySetList );
Network.hookPacket( PACKET.ZC.NORMAL_ITEMLIST3, onInventorySetList );
Network.hookPacket( PACKET.ZC.NORMAL_ITEMLIST4, onInventorySetList );
Network.hookPacket( PACKET.ZC.CART_NORMAL_ITEMLIST3, onCartSetList );
Network.hookPacket( PACKET.ZC.CART_EQUIPMENT_ITEMLIST3, onCartSetList );
Network.hookPacket( PACKET.ZC.NOTIFY_CARTITEM_COUNTINFO, onCartSetInfo );
Network.hookPacket( PACKET.ZC.EQUIPMENT_ITEMLIST, onInventorySetList );
Network.hookPacket( PACKET.ZC.EQUIPMENT_ITEMLIST2, onInventorySetList );
Network.hookPacket( PACKET.ZC.EQUIPMENT_ITEMLIST3, onInventorySetList );
Expand All @@ -369,12 +428,15 @@ define(function( require )
Network.hookPacket( PACKET.ZC.REQ_WEAR_EQUIP_ACK2, onItemEquip );
Network.hookPacket( PACKET.ZC.ACK_WEAR_EQUIP_V5, onItemEquip );
Network.hookPacket( PACKET.ZC.DELETE_ITEM_FROM_BODY, onIventoryRemoveItem );
Network.hookPacket( PACKET.ZC.DELETE_ITEM_FROM_CART, onCartRemoveItem );
Network.hookPacket( PACKET.ZC.USE_ITEM_ACK, onItemUseAnswer );
Network.hookPacket( PACKET.ZC.USE_ITEM_ACK2, onItemUseAnswer );
Network.hookPacket( PACKET.ZC.CONFIG_NOTIFY, onConfigEquip );
Network.hookPacket( PACKET.ZC.EQUIP_ARROW, onArrowEquipped );
Network.hookPacket( PACKET.ZC.ITEMCOMPOSITION_LIST, onItemCompositionList );
Network.hookPacket( PACKET.ZC.ACK_ITEMCOMPOSITION, onItemCompositionResult );
Network.hookPacket( PACKET.ZC.ACK_ITEMREFINING, onRefineResult);
Network.hookPacket( PACKET.ZC.ADD_ITEM_TO_CART, onCartItemAdded );
Network.hookPacket( PACKET.ZC.ADD_ITEM_TO_CART2, onCartItemAdded );
};
});
2 changes: 2 additions & 0 deletions src/Engine/MapEngine/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ define(function( require )
var WinStats = require('UI/Components/WinStats/WinStats');
var Announce = require('UI/Components/Announce/Announce');
var Equipment = require('UI/Components/Equipment/Equipment');
var ChangeCart = require('UI/Components/ChangeCart/ChangeCart');
var SkillList = require('UI/Components/SkillList/SkillList');
var PartyUI = require('UI/Components/PartyFriends/PartyFriends');

Expand Down Expand Up @@ -277,6 +278,7 @@ define(function( require )
case StatusProperty.CLEVEL:
BasicInfo.update('blvl', amount);
Equipment.onLevelUp();
ChangeCart.onLevelUp(amount);
break;

case StatusProperty.SKPOINT:
Expand Down
25 changes: 20 additions & 5 deletions src/Engine/MapEngine/Skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ define(function( require )
var ItemSelection = require('UI/Components/ItemSelection/ItemSelection');
var Inventory = require('UI/Components/Inventory/Inventory');
var NpcMenu = require('UI/Components/NpcMenu/NpcMenu');
var getModule = require;


/**
Expand Down Expand Up @@ -447,11 +448,25 @@ define(function( require )
if (!count) {
return;
}

pkt = new PACKET.CZ.USE_SKILL();
pkt.SKID = id;
pkt.selectedLevel = level;
pkt.targetID = targetID || Session.Entity.GID;


if(id === SkillId.MC_CHANGECART)
{
if(Session.Entity.hasCart == true)
{
getModule('UI/Components/ChangeCart/ChangeCart').onChangeCartSkill();
}
}
else if(id === SkillId.MC_VENDING)
{
getModule('UI/Components/Vending/Vending').onVendingSkill();
return;
}

pkt = new PACKET.CZ.USE_SKILL();
pkt.SKID = id;
pkt.selectedLevel = level;
pkt.targetID = targetID || Session.Entity.GID;

// In range
if (count < 2 || target === entity) {
Expand Down
25 changes: 25 additions & 0 deletions src/Engine/MapEngine/Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ define(function( require )
pkt.count = count;
Network.sendPacket( pkt );
};


Storage.reqAddItemFromCart = function reqAddItemFromCart( index, count )
{
if (count <= 0) {
return;
}

var pkt = new PACKET.CZ.MOVE_ITEM_FROM_CART_TO_STORE();
pkt.index = index;
pkt.count = count;
Network.sendPacket( pkt );
};


/**
Expand All @@ -132,6 +145,18 @@ define(function( require )
pkt.count = count;
Network.sendPacket( pkt );
};

Storage.reqMoveItemToCart = function reqMoveItemToCart( index, count )
{
if (count <= 0) {
return;
}

var pkt = new PACKET.CZ.MOVE_ITEM_FROM_STORE_TO_CART();
pkt.index = index;
pkt.count = count;
Network.sendPacket( pkt );
};


/**
Expand Down
83 changes: 83 additions & 0 deletions src/Engine/MapEngine/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,70 @@ define(function( require )
* Load dependencies
*/
var DB = require('DB/DBManager');
var Session = require('Engine/SessionStorage');
var Network = require('Network/NetworkManager');
var PACKET = require('Network/PacketStructure');
var EntityManager = require('Renderer/EntityManager');
var NpcStore = require('UI/Components/NpcStore/NpcStore');
var VendingShop = require('UI/Components/VendingShop/VendingShop');
var ChatBox = require('UI/Components/ChatBox/ChatBox');


/**
* Received items list to buy from cash npc
*
* @param {object} pkt - PACKET.ZC.ZC_PC_CASH_POINT_ITEMLIST
*/
function onBuyCashList( pkt )
{
NpcStore.append();
NpcStore.setType(NpcStore.Type.CASH_SHOP);
NpcStore.setList(pkt.itemList);

var entity = Session.Entity;
NpcStore.ui.find('.cashuser .buyer').text( entity ? entity.display.name : '');
NpcStore.ui.find('.cashuser .cashpoints').text(pkt.KafraPoint);

NpcStore.onSubmit = function(itemList) // add prompt confirmation first later...
{
var i, count;
var pkt;

pkt = new PACKET.CZ.PC_BUY_CASH_POINT_ITEM();
count = itemList.length;
pkt.kafrapts = 0;

for (i = 0; i < count; ++i)
{
pkt.list.push({
count: itemList[i].count,
ITID: itemList[i].ITID
});
//pkt.kafrapts += (itemList[i].discountprice || itemList[i].price) * itemList[i].count;
}

Network.sendPacket(pkt);
};
}


/**
* Received items list to buy from cash npc
*
* @param {object} pkt - PACKET.ZC.ZC_PC_CASH_POINT_ITEMLIST
*/
function onBuyVendingList( pkt )
{
VendingShop.append();
VendingShop.setItems(pkt.itemList);
}

function onDeleteVendingItem( pkt )
{
VendingShop.removeItem(pkt.index,pkt.count);
}


/**
* Received items list to buy from npc
*
Expand Down Expand Up @@ -72,6 +129,28 @@ define(function( require )
default: ChatBox.addText( DB.getMessage(57), ChatBox.TYPE.ERROR); break; // deal failed
}
}

/**
* Received purchased informations
*
* @param {object} pkt - PACKET_ZC_PC_CASH_POINT_UPDATE
*/

function onBuyCashResult( pkt )
{
NpcStore.remove();

switch (pkt.Error) {
case 0: ChatBox.addText( DB.getMessage(54), ChatBox.TYPE.BLUE); break; // success
case 1: ChatBox.addText( DB.getMessage(1227), ChatBox.TYPE.ERROR); break; // zeny
case 2: ChatBox.addText( DB.getMessage(1228), ChatBox.TYPE.ERROR); break; // overweight
case 4: ChatBox.addText( DB.getMessage(1229), ChatBox.TYPE.ERROR); break; // out of stock
case 5: ChatBox.addText( DB.getMessage(1230), ChatBox.TYPE.ERROR); break; // trade
case 6: ChatBox.addText( DB.getMessage(1254), ChatBox.TYPE.ERROR); break;
case 7: ChatBox.addText( DB.getMessage(1813), ChatBox.TYPE.ERROR); break; // no sale information
default: ChatBox.addText( DB.getMessage(1814), ChatBox.TYPE.ERROR); break; // deal failed
}
}


/**
Expand Down Expand Up @@ -174,12 +253,16 @@ define(function( require )
*/
return function MainEngine()
{
Network.hookPacket( PACKET.ZC.PC_CASH_POINT_ITEMLIST, onBuyCashList );
Network.hookPacket( PACKET.ZC.PC_CASH_POINT_UPDATE, onBuyCashResult );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_ITEMLIST, onBuyList );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_RESULT, onBuyResult );
Network.hookPacket( PACKET.ZC.PC_SELL_ITEMLIST, onSellList );
Network.hookPacket( PACKET.ZC.PC_SELL_RESULT, onSellResult );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_ITEMLIST_FROMMC, onVendingStoreList );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_ITEMLIST_FROMMC2, onVendingStoreList );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_RESULT_FROMMC, onBuyResult );
Network.hookPacket( PACKET.ZC.PC_PURCHASE_MYITEMLIST, onBuyVendingList );
Network.hookPacket( PACKET.ZC.DELETEITEM_FROM_MCSTORE, onDeleteVendingItem );
};
});
Loading