game/core1/static/scripts/location/comission.js
2022-06-07 00:30:34 +03:00

463 lines
19 KiB
JavaScript

// JavaScript Document
var locjs = {
data:{ },
type:0, //0 - ïðîñìîòð ðàçäåëîâ , 1 - ïðîñìîòð ðàçäåëîâ è êîíêðåòíîãî ïðåäìåòà , 2 - ïðîñìîòð ñâîèõ âåùåé (ñäà÷à) , 3 - ïðîñìîòð ñâîèõ âåùåé (çàáðàòü)
start:function() {
//this.htmlTitle();
//this.htmlMenu();
//this.htmlContent();
this.selectPoint(0,false);
//this.error('Îøèáêà ïîäêëþ÷åíèÿ ê áàçå.');
},
reflech:function() {
if( this.lookIt == 0 ) {
this.selectPoint( this.selectPointLast , false );
}else{
this.getBaseContent();
}
},
refleshData:function( data ) {
if( data.money != undefined ) {
this.data.user.money = data.money;
this.data.user.massaNow = data.massaNow;
this.data.user.massaMax = data.massaMax;
//
this.data.user.timeGo = data.timeGo;
this.data.user.timeGoL = data.timeGoL;
this.data.user.timeNow = data.timeNow;
this.htmlMenu();
}
locline.lineRefleshFinish();
},
htmlMenu:function() {
var r = '';
r += '<div align="right">';
//
r += '<div>' + locline.line( this.data.user.timeGo, this.data.user.timeGoL , this.data.user.timeNow , 'locjs.reflech();' ) +
'' + locline.room( this.data.locations ) + ''
+ '</div>';
//
r += '<small>';
r += '<span style="display:none">Ìàññà: <span id="u_massa">' + this.data.user.massaNow + '/' + this.data.user.massaMax + '</span><br></span>';
r += 'Ó âàñ â íàëè÷èè: <b style="color:#339900;" id="u_money">' + this.data.user.money + ' êð.</b><br><br>';
r += '</small></div>';
r += '<center>';
if( this.data.user.level >= 4 ) {
r += '<input id="comission_give" onclick="locjs.selectPoint(\'give\',true)" class="btn';
if( this.selectPointLast == 'give' ) {
r += '" disabled="disabled';
}
r += '" type="button" value="&nbsp; Ñäàòü âåùè &nbsp;" />';
r += '&nbsp;<input id="comission_pick" onclick="locjs.selectPoint(\'pick\',true)" class="btn';
if( this.selectPointLast == 'pick' ) {
r += '" disabled="disabled';
}
r += '" type="button" value="&nbsp; Çàáðàòü âåùè &nbsp;" />';
}
r += '<div style="background-color:#a5a5a5;padding:2px;margin-top:4px;" align="center"><b>Îòäåëû ìàãàçèíà</b></div>';
r += '</center>';
//Ïîêàçûâàåì ìåíþ
for (var i = 0; i < this.data.menu.length; i++) {
r += '<div id="comission_pid' + i + '" title="Ðàçäåë ¹' + i + '" onclick="locjs.selectPoint(' + i + ',true)" class="comission_menu_point';
if( this.selectPointLast == i ) {
r += ' comission_unhide';
}
r += '">';
if( this.data.menu[i][2] == 1 ) {
r += '&nbsp; &nbsp; &nbsp;';
}
r += '<a>' + this.data.menu[i][0] + '</a>';
r += '</div>';
}
r += '<div><small><br><font color="red"><b>Âíèìàíèå!</b> Ïðàâèëà ïîëüçîâàíèÿ êîìèññèîííûì ìàãàçèíîì:</font><br>';
r += '&bull; Ñ ïåðñîíàæà âçûìàåòñÿ íàëîã â âèäå <b>1 êð.</b> ïðè ïåðåäà÷è âåùè â ìàãàçèí.';
r += '<br>&bull; Íàëîã íå âîçâðàùàåòñÿ, åñëè âåùü íå áóäåò ïðîäàíà â òå÷åíèè äâóõ íåäåëü (Ñàìà âåùü ïðîäàåòñÿ â ãîñóäàðñòâåííûé ìàãàçèí çà 50% ñ ó÷åòîì èçíîñà ïðåäìåòà).';
r += '<br>&bull; Åñëè âåùü ïðîäàåòñÿ, âëàäåëüöó ïåðå÷èñëÿþòñÿ äåíüãè íà ïî÷òó çà âû÷åòîì êîìèññèîííûõ 10%. Íàëîã â 1 êð. âîçâðàùàåòñÿ.';
r += '<br>&bull; Àäìèíèñòðàöèÿ íå íåñåò îòâåòñòâåííîñòè çà óòðàòó âåùåé â ñëó÷àè ôîðñ ìàîæðíûõ ñèòóàöèé.';
//r += '<br>&bull; Åñëè âû íàøëè áàã èëè íåäî÷åò, ñîîáùèòå îá ýòîì çäåñü <a href="https://new-combats.com/forum/index.php?read=477" target="_blank">Áàãè â êîìèññèîííîì ìàãàçèíå</a>.';
r += '</small></div><br><br>';
return $('#comission_menu').html( r ) + locline.lineTimer()
//document.getElementById('comission_menu').innerHTML = r;
//return 'true';
},
selectPointLast:0,
selectPoint:function( p , clearError ) {
if( clearError == true ) {
this.error('');
}
this.baseconnect = true;
this.lookIt = 0;
this.type = 0;
$('#comission_pid' + this.selectPointLast + '').removeClass('comission_unhide');
this.selectPointLast = p;
//Âûáèðàåì ðàçäåë ïðåäìåòîâ
//$('#comission_pick').removeClass('btnnew');
//$('#comission_give').removeClass('btnnew');
//$('#comission_pick').removeClass('btnnew2');
//$('#comission_give').removeClass('btnnew2');
if( p == 'give' ) {
//Ñäàåì âåùè
this.data.base = this.getBaseContent();
//$('#comission_pick').addClass('btnnew');
//$('#comission_give').addClass('btnnew2');
this.htmlTitle();
this.htmlContent();
}else if( p == 'pick' ) {
//Çàáèðàåì
this.data.base = this.getBaseContent();
//$('#comission_give').addClass('btnnew');
//$('#comission_pick').addClass('btnnew2');
this.htmlTitle();
this.htmlContent();
}else{
//
this.data.base = this.getBaseContent();
//$('#comission_give').addClass('btnnew');
//$('#comission_pick').addClass('btnnew');
//
this.htmlTitle();
//this.htmlContent();
//this.htmlMenu();
//
$('#comission_pid' + this.selectPointLast + '').addClass('comission_unhide');
$("body").animate({"scrollTop":0},0);
}
},
htmlTitle:function() {
var r = '';
if( this.selectPointLast == 'give' ) {
r += 'Ñäà÷à âåùåé â êîìèññèîííûé ìàãàçèí';
}else if( this.selectPointLast == 'pick' ) {
r += 'Çàáðàòü ñâîè âåùè èç êîìèññèîííîãî ìàãàçèíà';
}else{
r += this.data.menu[this.selectPointLast][0];
if( r == '' ) {
r += '<i>Îòäåë ìàãàçèíà çàêðûò</i>';
}else{
r = r.charAt(0).toUpperCase() + r.substr(1);
r = 'Ðàçäåë: &quot;' + r + '&quot;';
}
}
return $('#comission_title').html( r );
},
baseconnect:false,
getBaseContent:function() {
//if( this.baseconnect == false ) {
locline.lineRefleshStart();
$.getJSON('/core/comission/', {
'point':this.selectPointLast, 'type':this.type, 'lookIt':this.lookIt
},function(data) {
locjs.refleshData( data );
locjs.baseconnect = false;
locjs.data.base = data;
locjs.htmlContent();
});
//}
},
lookIt:0,
lookItems:function( p ) {
this.lookIt = p;
this.type = 1;
this.getBaseContent();
},
buy_error:[ '','Ïðåäìåò íå íàéäåí, âîçìîæíî åãî êòî-òî óæå êóïèë','Ó âàñ íåäîñòàòî÷íî äåíåã','Õàîñíèêàì íåëüçÿ ïîëüçîâàòüñÿ êîìèññèîííûì ìàãàçèíîì','Ïåðñîíàæàì íèæå 1-ãî óðîâíÿ çàïðåùåíî ïîëüçîâàòüñÿ êîìèññèîííûì ìàãàçèíîì' ],
buy:function( cid , item_id ) {
if( this.baseconnect == false ) {
locline.lineRefleshStart();
this.baseconnect = true;
$.getJSON('/core/comission/', {
'buy_item':cid, 'items_id':item_id
},function(data) {
locjs.refleshData( data );
locjs.baseconnect = false;
if( data.buy_item != undefined && (data.buy_error == undefined || data.buy_error == 0) ) {
$("body").animate({"scrollTop":0},0);
$('#itm_com_' + data.buy_item).remove();
locjs.data.user.money -= parseFloat(data.buy_price).toFixed(2);
$('#u_money').html( locjs.data.user.money.toFixed(2) + ' êð.' );
locjs.data.user.massaNow += parseFloat(data.buy_massa).toFixed(2);
$('#u_massa').html( locjs.data.user.massaNow + '/' + locjs.data.user.massaMax );
locjs.error( 'Âû óñïåøíî êóïèëè ïðåäìåò &quot;' + data.buy_name + '&quot; çà ' + data.buy_price + ' êð.' );
if( data.buy_last < 1 ) {
locjs.selectPoint( locjs.selectPointLast , false );
}
}else if( locjs.buy_error[data.buy_error] != undefined ) {
$("body").animate({"scrollTop":0},0);
locjs.error( '' + locjs.buy_error[data.buy_error] );
}
});
}
},
newprice_error:[
'','Ïðåäìåò íå íàéäåí â ìàãàçèíå','Öåíà íå ìîæåò áûòü íèæå 1 êð.','Äëÿ äàííîãî ïðåäìåòà ýòî ñëèøêîì áîëüøàÿ ñòîèìîñòü...','Äëÿ äàííîãî ïðåäìåòà ýòî ñëèøêîì ìàëåíüêàÿ ñòîèìîñòü, âûãîäíåå îòðåìîíòèðîâàòü ïðåäìåò è ñäàòü åãî â ãîñóäàðñòâåííûé ìàãàçèí...'
],
newprice:function( id , price ) {
if( this.baseconnect == false ) {
locline.lineRefleshStart();
this.baseconnect = true;
$.getJSON('/core/comission/', {
'newprice_item':id , 'newprice_price':price
},function(data) {
locjs.refleshData( data );
locjs.baseconnect = false;
if( data.newprice_item != undefined && (data.newprice_error == undefined || data.newprice_error == 0) ) {
$("body").animate({"scrollTop":0},0);
locjs.data.user.money -= parseFloat(data.newprice_price_comission).toFixed(2);
$('#u_money').html( locjs.data.user.money.toFixed(2) + ' êð.' );
locjs.error( 'Âû îáíîâèëè öåíó &quot;' + data.newprice_name + '&quot; x' + data.newprice_x + ' øò. íà ' + data.newprice_price + ' êð. çà ' + data.newprice_price_comission + ' êð.' );
}else if( locjs.newprice_error[data.newprice_error] != undefined ) {
$("body").animate({"scrollTop":0},0);
if( data.newprice_error_min != undefined && data.newprice_error_min != '' ) {
locjs.error( '' + locjs.newprice_error[data.newprice_error] + ' (Ìèíèìàëüíàÿ öåíà: ' + data.newprice_error_min + ' êð.)' );
}else{
locjs.error( '' + locjs.newprice_error[data.newprice_error] );
}
}
});
}
},
give_error:['','Ïðåäìåò íå íàéäåí â èíâåíòàðå','Íåäîñòàòî÷íî äåíåã äëÿ óïëàòû êîìèññèè','Õàîñíèêàì íåëüçÿ ïîëüçîâàòüñÿ êîìèññèîííûì ìàãàçèíîì','Ïåðñîíàæàì íèæå 4-ãî óðîâíÿ çàïðåùåíî âûñòàâëÿòü âåùè â êîìèññèîííîì ìàãàçèíå',
'Öåíà íå ìîæåò áûòü áîëüøå 1 000 000 êð.','Öåíà íå ìîæåò áûòü íèæå 1 êð.','Äëÿ äàííîãî ïðåäìåòà ýòî ñëèøêîì áîëüøàÿ ñòîèìîñòü...','Äëÿ äàííîãî ïðåäìåòà ýòî ñëèøêîì ìàëåíüêàÿ ñòîèìîñòü, âûãîäíåå îòðåìîíòèðîâàòü ïðåäìåò è ñäàòü åãî â ãîñóäàðñòâåííûé ìàãàçèí...'
,'Êîìèññèîííûé ìàãàçèí íå ïðèíÿë âàøè âåùè'
],
give:function( id , price ) {
if( this.baseconnect == false ) {
locline.lineRefleshStart();
this.baseconnect = true;
$.getJSON('/core/comission/', {
'give_item':id , 'give_price':price
},function(data) {
locjs.refleshData( data );
locjs.baseconnect = false;
if( data.give_item != undefined && (data.give_error == undefined || data.give_error == 0) ) {
$("body").animate({"scrollTop":0},0);
$('#itm_usr_' + data.give_item).remove();
locjs.data.user.money -= parseFloat(data.give_price_comission).toFixed(2);
$('#u_money').html( locjs.data.user.money.toFixed(2) + ' êð.' );
locjs.data.user.massaNow -= parseFloat(data.give_massa).toFixed(2);
$('#u_massa').html( locjs.data.user.massaNow + '/' + locjs.data.user.massaMax );
locjs.error( 'Âû ñäàëè â ìàãàçèí &quot;' + data.give_name + '&quot; x' + data.give_x + ' øò. íà ñóììó ' + data.give_price + ' êð. çà ' + data.give_price_comission + ' êð.' );
if( data.give_last < 1 ) {
alert('Ïðåäìåòû â èíâåíòàðå çàêîí÷èëèñü :)');
}
}else if( locjs.give_error[data.give_error] != undefined ) {
$("body").animate({"scrollTop":0},0);
if( data.give_error_min != undefined && data.give_error_min != '' ) {
locjs.error( '' + locjs.give_error[data.give_error] + ' (Ìèíèìàëüíàÿ öåíà: ' + data.give_error_min + ' êð.)' );
}else{
locjs.error( '' + locjs.give_error[data.give_error] );
}
}
});
}
},
pick_error:[ '',
'Ïðåäìåò íå íàéäåí â ìàãàçèíå'
],
pick:function( id ) {
if( this.baseconnect == false ) {
locline.lineRefleshStart();
this.baseconnect = true;
$.getJSON('/core/comission/', {
'pick_item':id
},function(data) {
locjs.refleshData( data );
locjs.baseconnect = false;
if( data.pick_item != undefined && (data.pick_error == undefined || data.pick_error == 0) ) {
$("body").animate({"scrollTop":0},0);
$('#itm_usr_' + data.pick_uiid).remove();
locjs.data.user.massaNow += parseFloat(data.pick_massa).toFixed(2);
$('#u_massa').html( locjs.data.user.massaNow + '/' + locjs.data.user.massaMax );
locjs.error( 'Âû çàáðàëè èç ìàãàçèíà &quot;' + data.pick_name + '&quot; x' + data.pick_x + ' øò.' );
if( data.pick_last < 1 ) {
alert('Ïðåäìåòû â ìàãàçèíå çàêîí÷èëèñü :)');
}
}else if( locjs.pick_error[data.pick_error] != undefined ) {
$("body").animate({"scrollTop":0},0);
locjs.error( '' + locjs.pick_error[data.pick_error] );
}
});
}
},
console_sale:function(name, txt, kr) {
var s = prompt("Ñäàòü â ìàãàçèí \""+txt+"\" (íàëîã 1.00 êð.). Óêàæèòå öåíó:", kr);
if ((s != null) && (s != '') && (s >= 0)) {
locjs.give( name , s );
}
},
console_change:function(name, txt, id, category, kr) {
var s = prompt("Ñìåíèòü öåíó äëÿ ïðåäìåòà \""+txt+"\". Óêàæèòå íîâóþ öåíó:", kr);
if ((s != null) && (s != '') && (s>=1)) {
locjs.newprice( name , s );
}
},
htmlContent:function() {
var r = '';
if( this.data.base != undefined ) {
//
//this.error( '<hr>type: ' + this.type + ' , option: ' + this.selectPointLast + '<hr>' );
//
if( this.selectPointLast == 'give' ) {
var i = 0, color = 'c8c8c8', left = '', right = '';
r += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
while( i < this.data.base.it.i ) {
left = ''; right = ''; if( color == 'c8c8c8' ) { color = 'd4d4d4'; }else{ color = 'c8c8c8'; }
left += '<img src="https://img.new-combats.com/i/items/' + this.data.base.it[i][2] + '"><br>';
if( this.data.base.it[i][22] > 0 ) {
//left += '<small>(id' + this.data.base.it[i][22] + ')</small><br><br>';
}
//
if( this.data.base.it[i][6] != this.data.base.it[i][12] && this.data.base.it[i][12] > 1 ) {
this.data.base.it[i][6] = this.data.base.it[i][12];
}
if( this.data.base.it[i][21] > 0 && this.data.base.it['g'][this.data.base.it[i]['iid']][this.data.base.it[i][21]] > 0 ) {
this.data.base.it[i][6] = this.data.base.it[i][6] * parseFloat(this.data.base.it['g'][this.data.base.it[i]['iid']][this.data.base.it[i][21]]).toFixed(2);
this.data.base.it[i][6] = this.data.base.it[i][6].toFixed(2);
}
//
left += '<a href="javascript:void(0)" onclick="locjs.console_sale(' + this.data.base.it[i][22] + ',\'' + this.data.base.it[i][1] + '\',\'' + this.data.base.it[i][6] + '\');">Ñäàòü â ìàãàçèí</a>';
//
right += itmjs.infoItem( this.data.base.it , i , 'comission_give' );
//
r += '<tr bgcolor="#' + color + '" id="itm_usr_'+this.data.base.it[i][22]+'"><td width="160" align="center" class="borderitem px3px brd1top" valign="middle">' + left + '</td>';
r += '<td valign="top" class="px3px brd1top">' + right + '</td></tr>';
i++;
}
r += '</table>';
}else if( this.selectPointLast == 'pick' ) {
var i = 0, color = 'c8c8c8', left = '', right = '';
r += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
while( i < this.data.base.it.i ) {
left = ''; right = ''; if( color == 'c8c8c8' ) { color = 'd4d4d4'; }else{ color = 'c8c8c8'; }
left += '<img src="https://img.new-combats.com/i/items/' + this.data.base.it[i][2] + '"><br>';
if( this.data.base.it[i][22] > 0 ) {
//left += '<small>(id' + this.data.base.it[i][22] + ')</small><br><br>';
}
//
left += '<a href="javascript:void(0)" onclick="locjs.pick( ' + this.data.base.it[i]['cid'] + ');">Çàáðàòü ïðåäìåò</a><br>';
left += '<a href="javascript:void(0)" onclick="locjs.console_change(' + this.data.base.it[i][22] + ',\'' + this.data.base.it[i][1] + '\',\'' + this.data.base.it[i][6] + '\');">Ñìåíèòü öåíó çà 0.10 êð.</a>';
left += '<small><br><br>Äî ' + this.data.base.it[i]['timeend'] + '</small>';
//
right += itmjs.infoItem( this.data.base.it , i , 'comission_pick' );
//
r += '<tr bgcolor="#' + color + '" id="itm_usr_'+this.data.base.it[i][22]+'"><td width="160" align="center" class="borderitem px3px brd1top" valign="middle">' + left + '</td>';
r += '<td valign="top" class="px3px brd1top">' + right + '</td></tr>';
i++;
}
r += '</table>';
}else{
if( this.data.base.type == 1 ) {
var i = 0, color = 'c8c8c8', left = '', right = '';
r += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
while( i < this.data.base.it.i ) {
left = ''; right = ''; if( color == 'c8c8c8' ) { color = 'd4d4d4'; }else{ color = 'c8c8c8'; }
left += '<img src="https://img.new-combats.com/i/items/' + this.data.base.it[i][2] + '"><br>';
left += '<a href="javascript:void(0)" onclick="locjs.buy( ' + this.data.base.it[i]['cid'] + ' , ' + this.data.base.it[i]['iid'] + ' );">êóïèòü</a>';
//
right += itmjs.infoItem( this.data.base.it , i , 'comission' );
//
r += '<tr bgcolor="#' + color + '" id="itm_com_'+this.data.base.it[i]['cid']+'"><td width="160" align="center" class="borderitem px3px brd1top" valign="middle">' + left + '</td>';
r += '<td valign="top" class="px3px brd1top">' + right + '</td></tr>';
i++;
}
r += '</table>';
}else if( this.data.base.type == 0 ) {
var i = 0, color = 'c8c8c8', left = '', right = '';
r += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
while( i < this.data.base.it.i ) {
left = ''; right = ''; if( color == 'c8c8c8' ) { color = 'd4d4d4'; }else{ color = 'c8c8c8'; }
left += '<img src="https://img.new-combats.com/i/items/' + this.data.base.it[i][5] + '"><br><a href="javascript:void(0);" onclick="locjs.lookItems(' + this.data.base.it[i][1] + ');">ïîäðîáíåå</a>';
//
right += '<a href="https://new-combats.com/item/' + this.data.base.it[i][1] + '" target="_blank">' + this.data.base.it[i][4] + '</a>';
right += ' &nbsp;&nbsp; (Ìàññà: ' + this.data.base.it[i][6] + ')<br>';
right += '<b>Öåíà: ' + this.data.base.it[i][7][0] + ' - ' + this.data.base.it[i][7][1] + ' êð.</b>';
right += ' &nbsp; <small>(Êîëè÷åñòâî: ' + this.data.base.it[i][8] + ')</small><br>';
right += 'Äîëãîâå÷íîñòü: ' + this.data.base.it[i][2][0] + '-' + this.data.base.it[i][3][0] + ' / ' + this.data.base.it[i][2][1] + '-' + this.data.base.it[i][3][1] + '';
right += '<br><b>Òðåáóåòñÿ ìèíèìàëüíîå:</b><br>&bull; Óðîâåíü: ' + this.data.base.it[i][9] + '';
//
r += '<tr bgcolor="#' + color + '"><td width="160" align="center" class="borderitem px3px brd1top" valign="middle">' + left + '</td>';
r += '<td valign="top" class="px3px brd1top">' + right + '</td></tr>';
i++;
}
r += '</table>';
}
}
//
}else{
r += '<center class="borderandpadding5px"><i>Çàãðóçêà ñïèñêà âåùåé</i></center>';
}
if( this.selectPointLast == 'give' ) {
if( this.data.user.level < 4 ) {
r += '<center class="borderandpadding5px">Ñäà÷à âåùåé â êîìèññèîííûé ìàãàçèí ðàçðåøåíà ñ 4-ãî óðîâíÿ</center>';
}else if( r == '' ) {
r += '<center class="borderandpadding5px">Ó âàñ íåò ïðåäìåòîâ êîòîðûå ìîæíî ñäàòü â êîìèññèîííûé ìàãàçèí</center>';
}else{
}
}else if( this.selectPointLast == 'pick' ) {
if( r == '' ) {
r += '<center class="borderandpadding5px">Ó âàñ íåò ïðåäìåòîâ ñäàííûõ â êîìèññèîííûé ìàãàçèí</center>';
}else{
}
}else{
if( this.data.base == undefined || this.data.base.it.i == 0 ) {
r = '';
}
if( r == '' && this.baseconnect == false ) {
r += '<center class="borderandpadding5px">Ïðèëàâîê ìàãàçèíà ïóñò</center>';
}else{
}
}
if( r != '' ) {
$('#comission_content').html( r );
}
},
error:function( text ) {
$('#error').html( text );
if( text == '' ) {
$('#error').hide();
}else{
$('#error').show();
}
}
};