1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
function items(){}items.prototype.init=function(){this.items={yellowKey:{cls:"keys",name:"黄钥匙"},blueKey:{cls:"keys",name:"蓝钥匙"},redKey:{cls:"keys",name:"红钥匙"},redJewel:{cls:"items",name:"红宝石"},blueJewel:{cls:"items",name:"蓝宝石"},greenJewel:{cls:"items",name:"绿宝石"},yellowJewel:{cls:"items",name:"黄宝石"},redPotion:{cls:"items",name:"红血瓶"},bluePotion:{cls:"items",name:"蓝血瓶"},yellowPotion:{cls:"items",name:"黄血瓶"},greenPotion:{cls:"items",name:"绿血瓶"},sword1:{cls:"items",name:"铁剑"},sword2:{cls:"items",name:"银剑"},sword3:{cls:"items",name:"骑士剑"},sword4:{cls:"items",name:"圣剑"},sword5:{cls:"items",name:"神圣剑"},shield1:{cls:"items",name:"铁盾"},shield2:{cls:"items",name:"银盾"},shield3:{cls:"items",name:"骑士盾"},shield4:{cls:"items",name:"圣盾"},shield5:{cls:"items",name:"神圣盾"},superPotion:{cls:"items",name:"圣水"},moneyPocket:{cls:"items",name:"金钱袋"},book:{cls:"constants",name:"怪物手册",text:"可以查看当前楼层各怪物属性"},fly:{cls:"constants",name:"楼层传送器",text:"可以自由往来去过的楼层"},coin:{cls:"constants",name:"幸运金币",text:"持有时打败怪物可得双倍金币"},snow:{cls:"constants",name:"冰冻徽章",text:"可以将四周的熔岩变成平地"},cross:{cls:"constants",name:"十字架",text:"该道具尚未被定义"},knife:{cls:"constants",name:"屠龙匕首",text:"该道具尚未被定义"},shoes:{cls:"constants",name:"绿鞋",text:"持有时无视负面地形"},bigKey:{cls:"tools",name:"大黄门钥匙",text:"可以开启当前层所有黄门"},greenKey:{cls:"tools",name:"绿钥匙",text:"可以打开一扇绿门"},steelKey:{cls:"tools",name:"铁门钥匙",text:"可以打开一扇铁门"},pickaxe:{cls:"tools",name:"破墙镐",text:"可以破坏勇士面前的墙"},icePickaxe:{cls:"tools",name:"破冰镐",text:"可以破坏勇士面前的一堵冰墙"},bomb:{cls:"tools",name:"炸弹",text:"可以炸掉勇士四周的怪物"},centerFly:{cls:"tools",name:"中心对称飞行器",text:"可以飞向当前楼层中心对称的位置"},upFly:{cls:"tools",name:"上楼器",text:"可以飞往楼上的相同位置"},downFly:{cls:"tools",name:"下楼器",text:"可以飞往楼下的相同位置"},earthquake:{cls:"tools",name:"地震卷轴",text:"可以破坏当前层的所有墙"},poisonWine:{cls:"tools",name:"解毒药水",text:"可以解除中毒状态"},weakWine:{cls:"tools",name:"解衰药水",text:"可以解除衰弱状态"},curseWine:{cls:"tools",name:"解咒药水",text:"可以解除诅咒状态"},superWine:{cls:"tools",name:"万能药水",text:"可以解除所有不良状态"},hammer:{cls:"tools",name:"圣锤",text:"可以炸掉勇士面前的怪物"}}};items.prototype.getItems=function(){if(core.flags.bigKeyIsBox){this.items.bigKey={cls:"items",name:"钥匙盒"}}if(core.flags.pickaxeFourDirections){this.items.pickaxe.text="可以破坏勇士四周的墙"}return this.items};main.instance.items=new items();items.prototype.getItemEffect=function(b,c){var a=core.material.items[b].cls;if(a==="items"){if(b==="redJewel"){core.status.hero.atk+=core.values.redJewel}if(b==="blueJewel"){core.status.hero.def+=core.values.blueJewel}if(b==="greenJewel"){core.status.hero.mdef+=core.values.greenJewel}if(b=="yellowJewel"){core.status.hero.hp+=1000;core.status.hero.atk+=6;core.status.hero.def+=6;core.status.hero.mdef+=10}if(b==="redPotion"){core.status.hero.hp+=core.values.redPotion}if(b==="bluePotion"){core.status.hero.hp+=core.values.bluePotion}if(b==="yellowPotion"){core.status.hero.hp+=core.values.yellowPotion}if(b==="greenPotion"){core.status.hero.hp+=core.values.greenPotion}if(b==="sword1"){core.status.hero.atk+=core.values.sword1}if(b==="sword2"){core.status.hero.atk+=core.values.sword2}if(b=="sword3"){core.status.hero.atk+=core.values.sword3}if(b=="sword4"){core.status.hero.atk+=core.values.sword4}if(b==="sword5"){core.status.hero.atk+=core.values.sword5}if(b==="shield1"){core.status.hero.def+=core.values.shield1}if(b==="shield2"){core.status.hero.def+=core.values.shield2}if(b==="shield3"){core.status.hero.def+=core.values.shield3}if(b==="shield4"){core.status.hero.def+=core.values.shield4}if(b==="shield5"){core.status.hero.def+=core.values.shield5}if(b==="bigKey"){core.status.hero.items.keys.yellowKey++;core.status.hero.items.keys.blueKey++;core.status.hero.items.keys.redKey++}if(b=="superPotion"){core.status.hero.hp*=2}if(b=="moneyPocket"){core.status.hero.money+=core.values.moneyPocket}}else{core.addItem(b,c)}};items.prototype.getItemEffectTip=function(a){if(a==="redJewel"){return",攻击+"+core.values.redJewel}if(a==="blueJewel"){return",防御+"+core.values.blueJewel}if(a==="greenJewel"){return",魔防+"+core.values.greenJewel}if(a=="yellowJewel"){return",全属性提升"}if(a==="redPotion"){return",生命+"+core.values.redPotion}if(a==="bluePotion"){return",生命+"+core.values.bluePotion}if(a==="yellowPotion"){return",生命+"+core.values.yellowPotion}if(a==="greenPotion"){return",生命+"+core.values.greenPotion}if(a==="sword1"){return",攻击+"+core.values.sword1}if(a==="sword2"){return",攻击+"+core.values.sword2}if(a==="sword3"){return",攻击+"+core.values.sword3}if(a==="sword4"){return",攻击+"+core.values.sword4}if(a==="sword5"){return",攻击+"+core.values.sword5}if(a==="shield1"){return",防御+"+core.values.shield1}if(a==="shield2"){return",防御+"+core.values.shield2}if(a==="shield3"){return",防御+"+core.values.shield3}if(a==="shield4"){return",防御+"+core.values.shield4}if(a==="shield5"){return",防御+"+core.values.shield5}if(a==="bigKey"){return",全钥匙+1"}if(a==="superPotion"){return",生命值翻倍"}if(a=="moneyPocket"){return",金币+"+core.values.moneyPocket}return""};items.prototype.useItem=function(b){if(!this.canUseItem(b)){return}var a=core.material.items[b].cls;if(b=="book"){core.ui.drawEnemyBook(1)}if(b=="fly"){core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId))}if(b=="earthquake"||b=="bomb"||b=="pickaxe"||b=="icePickaxe"||b=="snow"||b=="hammer"||b=="bigKey"){core.removeBlockByIds(core.status.floorId,core.status.event.data);core.drawMap(core.status.floorId,function(){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");core.updateFg();core.drawTip(core.material.items[b].name+"使用成功");if(b=="bomb"&&core.flags.bombTrigger){core.events.afterBattle()}else{if(b=="hammer"&&core.flags.bombTrigger){core.events.afterBattle(core.status.event.data[0])}}})}if(b=="centerFly"){core.clearMap("hero",0,0,416,416);core.setHeroLoc("x",core.status.event.data.x);core.setHeroLoc("y",core.status.event.data.y);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");core.drawTip(core.material.items[b].name+"使用成功")}if(b=="upFly"||b=="downFly"){core.changeFloor(core.status.event.data.id,null,{direction:core.status.hero.loc.direction,x:core.status.event.data.x,y:core.status.event.data.y},null,function(){core.drawTip(core.material.items[b].name+"使用成功")})}if(b=="poisonWine"){core.setFlag("poison",false)}if(b=="weakWine"){core.setFlag("weak",false);core.status.hero.atk+=core.values.weakValue;core.status.hero.def+=core.values.weakValue}if(b=="curseWine"){core.setFlag("curse",false)}if(b=="superWine"){core.setFlag("poison",false);core.setFlag("weak",false);core.status.hero.atk+=core.values.weakValue;core.status.hero.def+=core.values.weakValue;core.setFlag("curse",false)}core.updateStatusBar();if(a=="tools"){core.status.hero.items[a][b]--}if(core.status.hero.items[a][b]==0){delete core.status.hero.items[a][b]}};items.prototype.canUseItem=function(h){if(!core.hasItem(h)){return false}var g=core.material.items[h].cls;if(h=="book"){return true}if(h=="fly"){return core.status.hero.flyRange.indexOf(core.status.floorId)>=0}if(h=="pickaxe"){var e=[];for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&(a.event.id=="yellowWall"||a.event.id=="whiteWall"||a.event.id=="blueWall")){if(core.flags.pickaxeFourDirections){if(Math.abs(a.x-core.status.hero.loc.x)+Math.abs(a.y-core.status.hero.loc.y)<=1){e.push(d)}}else{if(a.x==core.nextX()&&a.y==core.nextY()){e.push(d)}}}}if(e.length>0){core.status.event.data=e;return true}return false}if(h=="icePickaxe"){for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&a.x==core.nextX()&&a.y==core.nextY()&&a.event.id=="ice"){core.status.event.data=[d];return true}}return false}if(h=="bomb"){var e=[];for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&a.event.cls=="enemys"&&Math.abs(a.x-core.status.hero.loc.x)+Math.abs(a.y-core.status.hero.loc.y)<=1){var b=core.material.enemys[a.event.id];if(core.isset(b.bomb)&&!b.bomb){continue}e.push(d)}}if(e.length>0){core.status.event.data=e;return true}return false}if(h=="hammer"){for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&a.event.cls=="enemys"&&a.x==core.nextX()&&a.y==core.nextY()){var b=core.material.enemys[a.event.id];if(core.isset(b.bomb)&&!b.bomb){continue}core.status.event.data=[d];return true}}return false}if(h=="earthquake"){var e=[];for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&(a.event.id=="yellowWall"||a.event.id=="blueWall"||a.event.id=="whiteWall")){e.push(d)}}if(e.length>0){core.status.event.data=e;return true}return false}if(h=="centerFly"){var k=12-core.getHeroLoc("x"),l=12-core.getHeroLoc("y");var a=core.getBlock(k,l);if(a==null){core.status.event.data={x:k,y:l};return true}return false}if(h=="upFly"){var c=core.status.floorId;var f=core.floorIds.indexOf(c);if(f==core.floorIds.length-1){return false}var j=core.floorIds[f+1];var k=core.getHeroLoc("x"),l=core.getHeroLoc("y");var a=core.getBlock(k,l,j);if(a==null){core.status.event.data={id:j,x:k,y:l};return true}return false}if(h=="downFly"){var c=core.status.floorId;var f=core.floorIds.indexOf(c);if(f==0){return false}var j=core.floorIds[f-1];var k=core.getHeroLoc("x"),l=core.getHeroLoc("y");var a=core.getBlock(k,l,j);if(a==null){core.status.event.data={id:j,x:k,y:l};return true}return false}if(h=="snow"){var e=[];for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&a.event.id=="lava"&&Math.abs(a.x-core.status.hero.loc.x)+Math.abs(a.y-core.status.hero.loc.y)<=1){e.push(d)}}if(e.length>0){core.status.event.data=e;return true}return false}if(h=="bigKey"){var e=[];for(var d in core.status.thisMap.blocks){var a=core.status.thisMap.blocks[d];if(core.isset(a.event)&&!(core.isset(a.enable)&&!a.enable)&&a.event.id=="yellowDoor"){e.push(d)}}if(e.length>0){core.status.event.data=e;return true}return false}if(h=="poisonWine"){return core.hasFlag("poison")}if(h=="weakWine"){return core.hasFlag("weak")}if(h=="curseWine"){return core.hasFlag("curse")}if(h=="superWine"){return core.hasFlag("poison")||core.hasFlag("weak")||core.hasFlag("curse")}return false}; |