本文整理汇总了TypeScript中utils/ErrorMapper.ErrorMapper类的典型用法代码示例。如果您正苦于以下问题:TypeScript ErrorMapper类的具体用法?TypeScript ErrorMapper怎么用?TypeScript ErrorMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorMapper类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: RoomManager
import { ErrorMapper } from "utils/ErrorMapper";
import {HarvesterRole} from "roles/harvester"
import {RoomManager} from "roomManager"
import { UpgraderRole } from "roles/upgrader";
import {BuilderRole} from "roles/builder";
var firstRoomName = Object.keys(Game.rooms)[0];
var roomManager = new RoomManager(firstRoomName, new HarvesterRole(), new BuilderRole(), new UpgraderRole());
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
// This utility uses source maps to get the line numbers and file names of the original, TS source code
export const loop = ErrorMapper.wrapLoop(() => {
roomManager.run();
});
开发者ID:elacy,项目名称:screeps,代码行数:15,代码来源:main.ts
示例2:
import { ErrorMapper } from "utils/ErrorMapper";
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
// This utility uses source maps to get the line numbers and file names of the original, TS source code
export const loop = ErrorMapper.wrapLoop(() => {
console.log(`Current game tick is ${Game.time}`);
// Automatically delete memory of missing creeps
for (const name in Memory.creeps) {
if (!(name in Game.creeps)) {
delete Memory.creeps[name];
}
}
});
开发者ID:covertcj,项目名称:screeps,代码行数:14,代码来源:main.ts
示例3: setupMem
import {RoomState, RoomType} from "shared";
import "source";
import "structures/structure";
import "tombstone";
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
// This utility uses source maps to get the line numbers and file names of the original, TS source code
export const loop = ErrorMapper.wrapLoop(() => {
setupMem();
clearMem();
const pct = Game.gcl.progress / Game.gcl.progressTotal * 100;
const pctStr = pct.toFixed(1);
if (Memory.vars.lastPct != pctStr) {
console.log(`GCL Progress: ${pctStr}%`);
Memory.vars.lastPct = pctStr;
}
const rooms = Memory.config.rooms.map((name) => Game.rooms[name]).filter((r) => r != null);
rooms.sort((r) => r.energyAvailable).reverse();
for (const room of rooms) {
room.run();
}
_.forOwn(Game.creeps, (creep) => {
creep.run();
});
});
export const setupMem = () => {
if (Memory.testing == null) {
Memory.testing = false;
}
if (Memory.vars == null) {
Memory.vars = {};
开发者ID:spacerecycler,项目名称:screeps-ai,代码行数:32,代码来源:main.ts
示例4: programClearMemory
import { ErrorMapper } from "utils/ErrorMapper";
import { programClearMemory } from "programs/program.ClearMemory";
import { programSpawnCreep } from "programs/program.SpawnCreep";
import { programMapActions } from "programs/program.MapActions";
import { programInitializeRoomMemory } from "programs/program.InitializeRoomMemory";
import { programTowerDefense } from "programs/program.TowerDefense";
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
// This utility uses source maps to get the line numbers and file names of the original, TS source code
export const loop = ErrorMapper.wrapLoop(() => {
//console.log(`Current game tick is ${Game.time}`);
let clearMemory: programClearMemory = new programClearMemory();
let spawnCreep: programSpawnCreep = new programSpawnCreep();
let mapActions: programMapActions = new programMapActions();
let towerDefense: programTowerDefense = new programTowerDefense();
let initializeRoomMemory: programInitializeRoomMemory = new programInitializeRoomMemory();
initializeRoomMemory.Run();
clearMemory.Run();
spawnCreep.Run();
mapActions.Run();
towerDefense.Run();
});
开发者ID:GrifterInk,项目名称:Screeps,代码行数:28,代码来源:main.ts
示例5: Neuralyzer
import { ErrorMapper } from "utils/ErrorMapper";
import { Neuralyzer } from "utils/Neuralyzer";
import Runtime from "Runtime";
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
// This utility uses source maps to get the line numbers and file names of the original, TS source code
export const loop = ErrorMapper.wrapLoop(() => {
console.log(`Current game tick is ${Game.time}`);
Neuralyzer();
Runtime.loop();
});
开发者ID:joepurdy,项目名称:digital-antfarm,代码行数:11,代码来源:main.ts
示例6: if
export const loop = ErrorMapper.wrapLoop(() => {
profiler.wrap(() => {
utilityFunctions.respawn();
utilityFunctions.clearDeadCreepMemory();
utilityFunctions.clearMissingFlagMemory();
// cleanup dead claimer
if (Memory.claimerName && !Game.creeps[Memory.claimerName]) {
Memory.claimerName = undefined;
}
// cleanup dead colonists
for (const name in Memory.colonistNames) {
if (!Game.creeps[name]) {
delete Memory.colonistNames[name];
}
}
// count my rooms (used for determining if I can expand)
const myRooms = _.filter(Game.rooms, { controller: { my: true}});
const myRoomCount = _.size(myRooms);
towerFunctions.runTowerLogic();
// Number of creeps that should exist for a given role. May vary by RCL.
const creepRoleCountsByRcl = {
rcl1: {
builder: 2,
courier: 3,
upgrader: 3
},
rcl4: {
builder: 1,
courier: 2,
upgrader: 1
}
};
for (const roomName in Game.rooms) {
const room = Game.rooms[roomName];
roomFunctions.checkForSources(room);
// if there is a newClaim in one of my rooms, delete it and replace
// it with a newColony if there is not already a newColony.
const claimFlag = Game.flags[roleClaimer.newClaimFlagName];
if (claimFlag &&
!Game.flags[roleColonist.newColonyFlagName] &&
Game.rooms[claimFlag.pos.roomName] &&
Game.rooms[claimFlag.pos.roomName].controller &&
Game.rooms[claimFlag.pos.roomName].controller!.my) {
// replace newClaim with newColony in the same position
claimFlag.pos.createFlag(roleColonist.newColonyFlagName, COLOR_PURPLE);
claimFlag.remove();
}
// handle a new colony. Decides to build a spawn in,
// abandon, or finish a colony.
const colonyFlag = Game.flags[roleColonist.newColonyFlagName];
if (colonyFlag) {
if (!colonyFlag.room!.controller!.my) {
// If the colony is in a room that is not mine, abandon it.
console.log("Colony room not owned by me. Abandoning colony: " + colonyFlag.room!.name);
Memory.colonySpawnSiteID = undefined;
colonyFlag.remove();
} else if (!Memory.colonySpawnSiteID) {
// If the spawn constructionSite is not in memory, get it.
colonyFlag.pos.createConstructionSite(STRUCTURE_SPAWN);
const colonySpawnSites = colonyFlag.room!.find(FIND_MY_CONSTRUCTION_SITES, {
filter: (constructionSite) => constructionSite.structureType === STRUCTURE_SPAWN
});
if (colonySpawnSites.length && colonySpawnSites[0].id) {
Memory.colonySpawnSiteID = colonySpawnSites[0].id;
}
} else if (Memory.colonySpawnSiteID && !Game.getObjectById(Memory.colonySpawnSiteID)) {
// If we can't find the spawn constructionSite, it either finished
// or was destroyed. Either way, delete the colony flag.
console.log("Colony spawn finished/destroyed. removing colony flag in: " + colonyFlag.room!.name);
Memory.colonySpawnSiteID = undefined;
colonyFlag.remove();
}
}
const creepsOfRole: any = {};
for (const roleName in roles) {
creepsOfRole[roleName] = {};
}
const roomCreeps = room.find(FIND_MY_CREEPS);
for (const creepIndex in roomCreeps) {
const creep = roomCreeps[creepIndex];
if (roles[creep.memory.role]) {
creepsOfRole[creep.memory.role][creep.name] = creep.id;
roles[creep.memory.role].run(creep);
}
}
if (room.controller && room.controller.my) {
//.........这里部分代码省略.........
开发者ID:AlexABallWebDev,项目名称:screeps-scripts,代码行数:101,代码来源:main.ts
注:本文中的utils/ErrorMapper.ErrorMapper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论