if ( typeof MCS == "undefined" ) {code highlighting : highlight.hohli.com
alert ( 'Bookmarklet needs to be called only on the monopoly page' ) ;
throw '' ;
}
var buildingType = null ;
var player = MCS. getPlayerData ( ) ;
if ( player == null ) {
alert ( 'Before calling, you must log in' ) ;
throw '' ;
}
var streetId = MCS. STREET . getStreetData ( ) . id ;
var streetData = MCS. STREET . getStreetData ( ) . data ;
if ( streetId == null ) {
alert ( 'Before calling, select the street' ) ;
throw '' ;
} else if ( streetData. o ! = player. nickname ) {
alert ( 'Before calling, you must choose your street' ) ;
throw '' ;
}
var locations = new Array ( ) ;
var builtCnt = 0 ;
var buildLimit = 0 ;
function buy ( ) {
if ( builtCnt < buildLimit ) {
buyBuilding ( locations [ 0 ] ) ;
MCS. STATUSBAR . redraw ( ) ;
getLocations ( ) ;
setTimeout ( buy , 250 ) ;
} else {
done ( ) ;
}
}
function done ( )
{
MCS. STREET . show ( streetId , null , false , false ) ;
MCS. LOADING . hide ( ) ;
alert ( 'Built buildings:' + builtCnt + 'pcs.' ) ;
}
function getLocations ( )
{
locations = new Array ( ) ;
$. ajax ( {
url : "/ build / getlocations" ,
cache : false ,
data : {
id : streetId ,
type : buildingType
} ,
dataType : "json" ,
async : false ,
success : function ( data , status ) {
$. each ( data , function ( foo , point ) {
if ( point ) {
locations. push ( foo ) ;
}
} ) ;
}
} ) ;
}
function buyBuilding ( location )
{
$. ajax ( {
url : "/ negotiate / buybuilding" ,
type : "post" ,
data : {
nickname : player. nickname ,
hash : player. hash ,
id : streetId ,
type : buildingType ,
loc : location
} ,
dataType : "json" ,
async : false ,
success : function ( data , status ) {
player. balance - = MCS. buildings [ buildingType ] . price ;
builtCnt ++;
}
} ) ;
MCS. TRACK . view ( {
page : "build" ,
section : "build" ,
street : streetData. n ,
country : streetData. cy ,
region : streetData. re ,
building_type : buildingType ,
activity : "build property" ,
value : MCS. buildings [ buildingType ] . price
} ) ;
}
buildingType = prompt ( 'Enter building identifier. List of available types can be found by typing "?"' , '?' ) ;
if ( buildingType ! = null ) {
if ( buildingType == '?' ) {
var string = '' ;
for ( i in MCS. buildings ) {
if ( ! isNaN ( MCS. buildings [ i ] . effect ) ) {
string = string + "ID:" + i + ", name:" + MCS. Lang building [ "building" + i ] + ", cost:" + MCS. buildings [ i ] . price * 1000 + " \ n " ;
}
}
alert ( string ) ;
} else if ( typeof MCS. buildings [ buildingType ] == "undefined" || isNaN ( MCS. buildings [ buildingType ] . effect ) ) {
alert ( "An invalid identifier is specified" ) ;
} else {
var count = Math. floor ( player. balance / MCS. buildings [ buildingType ] . price ) ;
if ( count > 0 ) {
getLocations ( ) ;
var minCnt = Math. min ( count , locations. length ) ;
if ( minCnt == 0 ) {
alert ( "On the street there is no place for buildings of this type" ) ;
} else {
buildLimit = minCnt ;
if ( ! confirm ( 'Now we will try to build houses in the amount of' + minCnt + 'pcs. If you want to change the limit (only down), click "cancel"' ) ) {
buildLimit = prompt ( 'How many buildings to try to build?' , minCnt ) ;
if ( buildLimit == null ) {
throw '' ;
}
if ( isNaN ( buildLimit ) || buildLimit > minCnt || buildLimit < 0 ) {
alert ( 'Incorrect value' ) ;
throw '' ;
}
}
MCS. LOADING . show ( ) ;
setTimeout ( buy , 250 ) ;
}
} else {
alert ( 'You do not have enough money to build this building' ) ;
}
}
}
javascript:if(typeof MCS != "undefined"&&MCS.STREET.getStreetData().data)alert(MCS.STREET.getStreetData().data.p*1000);
if ( typeof MCS == "undefined" ) {
alert ( 'Bookmarklet needs to be called only on the monopoly page' ) ;
throw '' ;
}
var buildingType = null ;
var player = MCS. getPlayerData ( ) ;
if ( player == null ) {
alert ( 'Before calling, you must log in' ) ;
throw '' ;
}
var streetId = MCS. STREET . getStreetData ( ) . id ;
var streetData = MCS. STREET . getStreetData ( ) . data ;
if ( streetId == null ) {
alert ( 'Before calling, select the street' ) ;
throw '' ;
} else if ( streetData. o ! = player. nickname ) {
alert ( 'Before calling, you must choose your street' ) ;
throw '' ;
}
function demolish ( ) {
if ( removedCnt < removeCnt && buildingList. length ) {
$. ajax ( {
url : "/ negotiate / demolishbuilding" ,
type : "post" ,
data : {
nickname : player. nickname ,
hash : player. hash ,
id : streetId ,
bid : buildingList. shift ( )
} ,
dataType : "json" ,
async : false ,
success : function ( ) {
MCS. getPlayerData ( ) . balance + = parseInt ( MCS. buildings [ removeMe ] . price / 2 ) ;
}
} ) ;
removedCnt ++;
setTimeout ( demolish , 500 ) ;
} else {
done ( ) ;
}
}
function done ( )
{
MCS. STREET . show ( streetId , null , false , false ) ;
MCS. LOADING . hide ( ) ;
}
var buildingTypes = new Array ( ) ;
var str = '' ;
var i ;
for ( i in streetData. b ) {
if ( ! isNaN ( MCS. buildings [ streetData. b [ i ] . t ] . effect ) ) {
if ( typeof buildingTypes [ streetData. b [ i ] . t ] == "undefined" ) {
buildingTypes [ streetData. b [ i ] . t ] = new Array ( ) ;
buildingTypes [ streetData. b [ i ] . t ] [ 'name' ] = MCS. Lang building [ "building" + streetData. b [ i ] . t ] ;
buildingTypes [ streetData. b [ i ] . t ] [ 'count' ] = 1 ;
} else {
buildingTypes [ streetData. b [ i ] . t ] [ 'count' ] ++;
}
}
}
if ( buildingTypes. length == 0 ) {
alert ( 'There are no buildings available for demolition on the selected street' ) ;
throw '' ;
}
for ( i in buildingTypes ) {
str = str + "ID:" + i + ", name:" + buildingTypes [ i ] [ 'name' ] + ", number:" + buildingTypes [ i ] [ 'count' ] + "pcs." + " \ n " ;
}
var removeMe = prompt ( "Enter the ID of the building to demolish. List of buildings on the street: \ n " + str ) ;
var buildingList = new Array ( ) ;
if ( removeMe ! = null ) {
if ( typeof buildingTypes [ removeMe ] == 'undefined' ) {
alert ( 'Invalid building type specified' ) ;
throw '' ;
}
var removeCnt = buildingTypes [ removeMe ] [ 'count' ] ;
var removedCnt = 0 ;
if ( ! confirm ( 'An attempt will be made to demolish buildings in the amount of' + removeCnt + 'pcs. If you want to change the quantity (only down), click "cancel"' ) ) {
removeCnt = prompt ( 'Enter the number of houses to demolish' ) ;
if ( removeCnt == null ) {
throw '' ;
}
if ( isNaN ( removeCnt ) || removeCnt > buildingTypes [ removeMe ] [ 'count' ] || removeCnt < 0 ) {
alert ( 'Incorrect value' ) ;
throw '' ;
}
}
MCS. LOADING . show ( ) ;
for ( i in streetData. b ) {
if ( streetData. b [ i ] . t == removeMe && removedCnt < removeCnt ) {
buildingList. push ( i ) ;
}
}
setTimeout ( demolish , 250 ) ;
}
Source: https://habr.com/ru/post/73164/
All Articles