1
0
Fork 0

Added typings

This commit is contained in:
Michaël Lemaire 2017-01-03 23:17:52 +01:00
parent 59f5e6b61b
commit c84bac7d59
45 changed files with 27 additions and 8200 deletions

1
.gitignore vendored
View File

@ -4,4 +4,5 @@
/out/vendor
/out/build.*
/graphics/**/*.blend?*
/typings/
*.log

View File

@ -4,9 +4,10 @@
"description": "A tactical RPG set in space",
"main": "src/build.js",
"scripts": {
"deps": "bower install",
"deps": "bower install && typings install",
"build": "tsc -p .",
"test": "jasmine",
"build-test": "tsc -p . && jasmine",
"cover": "istanbul cover node_modules/jasmine/bin/jasmine.js && remap-istanbul -i coverage/coverage.json -o coverage -t html",
"serve": "simple-server out 8012"
},
@ -17,11 +18,12 @@
"author": "Michael Lemaire",
"license": "MIT",
"devDependencies": {
"bower": "^1.7.9",
"jasmine": "^2.5.2",
"istanbul": "0.4",
"remap-istanbul": "0.6",
"simple-server": "^1.0.1",
"typescript": "^2.0.6"
"bower": "~1.8",
"istanbul": "~0.4",
"jasmine": "~2.5",
"remap-istanbul": "~0.6",
"simple-server": "~1.0",
"typescript": "~2.1",
"typings": "~1.4"
}
}
}

View File

@ -1,4 +1,4 @@
/// <reference path="definitions/phaser.d.ts"/>
/// <reference path="../typings/index.d.ts"/>
module SpaceTac {
"use strict";
@ -35,7 +35,7 @@ module SpaceTac {
// Save current game in local browser storage
saveGame(): boolean {
if (typeof(Storage) !== "undefined") {
if (typeof (Storage) !== "undefined") {
localStorage.setItem("spacetac-savegame", this.session.saveToString());
(<View.BaseView>this.state.getCurrentState()).messages.addMessage("Game saved");
return true;
@ -47,7 +47,7 @@ module SpaceTac {
// Load current game from local browser storage
loadGame(): boolean {
if (typeof(Storage) !== "undefined") {
if (typeof (Storage) !== "undefined") {
var loaded = localStorage.getItem("spacetac-savegame");
if (loaded) {
this.session = Game.GameSession.loadFromString(loaded);

View File

@ -1,429 +0,0 @@
// Type definitions for Jasmine 2.0
// Project: http://pivotal.github.com/jasmine/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
declare function describe(description: string, specDefinitions: () => void): void;
// declare function ddescribe(description: string, specDefinitions: () => void): void; Not a part of jasmine. Angular team adds these
declare function xdescribe(description: string, specDefinitions: () => void): void;
declare function it(expectation: string, assertion?: () => void): void;
declare function it(expectation: string, assertion?: (done: () => void) => void): void;
// declare function iit(expectation: string, assertion?: () => void): void; Not a part of jasmine. Angular team adds these
// declare function iit(expectation: string, assertion?: (done: () => void) => void): void; Not a part of jasmine. Angular team adds these
declare function xit(expectation: string, assertion?: () => void): void;
declare function xit(expectation: string, assertion?: (done: () => void) => void): void;
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
declare function pending(): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: () => void) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: () => void) => void): void;
declare function expect(spy: Function): jasmine.Matchers;
declare function expect(actual: any): jasmine.Matchers;
declare function spyOn(object: any, method: string): jasmine.Spy;
declare function runs(asyncMethod: Function): void;
declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
declare function waits(timeout?: number): void;
declare module jasmine {
var clock: () => Clock;
function any(aclass: any): Any;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
function pp(value: any): string;
function getEnv(): Env;
function addMatchers(matchers: any): Any;
interface Any {
new (expectedClass: any): any;
jasmineMatches(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
}
interface Block {
new (env: Env, func: SpecFunction, spec: Spec): any;
execute(onComplete: () => void): void;
}
interface WaitsBlock extends Block {
new (env: Env, timeout: number, spec: Spec): any;
}
interface WaitsForBlock extends Block {
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
}
interface Clock {
install(): void;
uninstall(): void;
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
tick(ms: number): void;
}
interface Env {
setTimeout: any;
clearTimeout: void;
setInterval: any;
clearInterval: void;
updateInterval: number;
currentSpec: Spec;
matchersClass: Matchers;
version(): any;
versionString(): string;
nextSpecId(): number;
addReporter(reporter: Reporter): void;
execute(): void;
describe(description: string, specDefinitions: () => void): Suite;
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
beforeEach(beforeEachFunction: () => void): void;
currentRunner(): Runner;
afterEach(afterEachFunction: () => void): void;
xdescribe(desc: string, specDefinitions: () => void): XSuite;
it(description: string, func: () => void): Spec;
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
xit(desc: string, func: () => void): XSpec;
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
contains_(haystack: any, needle: any): boolean;
addEqualityTester(equalityTester: (a: any, b: any, env: Env, mismatchKeys: string[], mismatchValues: string[]) => boolean): void;
specFilter(spec: Spec): boolean;
}
interface FakeTimer {
new (): any;
reset(): void;
tick(millis: number): void;
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
}
interface HtmlReporter {
new (): any;
}
interface HtmlSpecFilter {
new (): any;
}
interface Result {
type: string;
}
interface NestedResults extends Result {
description: string;
totalCount: number;
passedCount: number;
failedCount: number;
skipped: boolean;
rollupCounts(result: NestedResults): void;
log(values: any): void;
getItems(): Result[];
addResult(result: Result): void;
passed(): boolean;
}
interface MessageResult extends Result {
values: any;
trace: Trace;
}
interface ExpectationResult extends Result {
matcherName: string;
passed(): boolean;
expected: any;
actual: any;
message: string;
trace: Trace;
}
interface Trace {
name: string;
message: string;
stack: any;
}
interface PrettyPrinter {
new (): any;
format(value: any): void;
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
emitScalar(value: any): void;
emitString(value: string): void;
emitArray(array: any[]): void;
emitObject(obj: any): void;
append(value: any): void;
}
interface StringPrettyPrinter extends PrettyPrinter {
}
interface Queue {
new (env: any): any;
env: Env;
ensured: boolean[];
blocks: Block[];
running: boolean;
index: number;
offset: number;
abort: boolean;
addBefore(block: Block, ensure?: boolean): void;
add(block: any, ensure?: boolean): void;
insertNext(block: any, ensure?: boolean): void;
start(onComplete?: () => void): void;
isRunning(): boolean;
next_(): void;
results(): NestedResults;
}
interface Matchers {
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
env: Env;
actual: any;
spec: Env;
isNot?: boolean;
message(): any;
toBe(expected: any): boolean;
toEqual(expected: any): boolean;
toMatch(expected: any): boolean;
toBeDefined(): boolean;
toBeUndefined(): boolean;
toBeNull(): boolean;
toBeNaN(): boolean;
toBeTruthy(): boolean;
toBeFalsy(): boolean;
toHaveBeenCalled(): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toContain(expected: any): boolean;
toBeLessThan(expected: any): boolean;
toBeGreaterThan(expected: any): boolean;
toBeCloseTo(expected: any, precision: any): boolean;
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
toThrow(expected?: any): boolean;
toThrowError(expected?: any): boolean;
not: Matchers;
Any: Any;
}
interface Reporter {
reportRunnerStarting(runner: Runner): void;
reportRunnerResults(runner: Runner): void;
reportSuiteResults(suite: Suite): void;
reportSpecStarting(spec: Spec): void;
reportSpecResults(spec: Spec): void;
log(str: string): void;
}
interface MultiReporter extends Reporter {
addReporter(reporter: Reporter): void;
}
interface Runner {
new (env: Env): any;
execute(): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
finishCallback(): void;
addSuite(suite: Suite): void;
add(block: Block): void;
specs(): Spec[];
suites(): Suite[];
topLevelSuites(): Suite[];
results(): NestedResults;
}
interface SpecFunction {
(spec?: Spec): void;
}
interface SuiteOrSpec {
id: number;
env: Env;
description: string;
queue: Queue;
}
interface Spec extends SuiteOrSpec {
new (env: Env, suite: Suite, description: string): any;
suite: Suite;
afterCallbacks: SpecFunction[];
spies_: Spy[];
results_: NestedResults;
matchersClass: Matchers;
getFullName(): string;
results(): NestedResults;
log(arguments: any): any;
runs(func: SpecFunction): Spec;
addToQueue(block: Block): void;
addMatcherResult(result: Result): void;
expect(actual: any): any;
waits(timeout: number): Spec;
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
fail(e?: any): void;
getMatchersClass_(): Matchers;
addMatchers(matchersPrototype: any): void;
finishCallback(): void;
finish(onComplete?: () => void): void;
after(doAfter: SpecFunction): void;
execute(onComplete?: () => void): any;
addBeforesAndAftersToQueue(): void;
explodes(): void;
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
removeAllSpies(): void;
}
interface XSpec {
id: number;
runs(): void;
}
interface Suite extends SuiteOrSpec {
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
parentSuite: Suite;
getFullName(): string;
finish(onComplete?: () => void): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
results(): NestedResults;
add(suiteOrSpec: SuiteOrSpec): void;
specs(): Spec[];
suites(): Suite[];
children(): any[];
execute(onComplete?: () => void): void;
}
interface XSuite {
execute(): void;
}
interface Spy {
(...params: any[]): any;
identity: string;
and: SpyAnd;
calls: Calls;
mostRecentCall: { args: any[]; };
argsForCall: any[];
wasCalled: boolean;
callCount: number;
}
interface SpyAnd {
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
callThrough(): void;
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
returnValue(val: any): void;
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
callFake(fn: Function): void;
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
throwError(msg: string): void;
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
stub(): void;
}
interface Calls {
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
any(): boolean;
/** By chaining the spy with calls.count(), will return the number of times the spy was called **/
count(): number;
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
argsFor(index: number): any[];
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
allArgs(): any[];
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
all(): any;
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
mostRecent(): any;
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
first(): any;
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
reset(): void;
}
interface Util {
inherit(childClass: Function, parentClass: Function): any;
formatException(e: any): any;
htmlEscape(str: string): string;
argsToArray(args: any): any;
extend(destination: any, source: any): any;
}
interface JsApiReporter extends Reporter {
started: boolean;
finished: boolean;
result: any;
messages: any;
new (): any;
suites(): Suite[];
summarize_(suiteOrSpec: SuiteOrSpec): any;
results(): any;
resultsForSpec(specId: any): any;
log(str: any): any;
resultsForSpecs(specIds: any): any;
summarizeResult_(result: any): any;
}
interface Jasmine {
Spec: Spec;
clock: Clock;
util: Util;
}
export var HtmlReporter: HtmlReporter;
export var HtmlSpecFilter: HtmlSpecFilter;
export var DEFAULT_TIMEOUT_INTERVAL: number;
}

View File

@ -1,948 +0,0 @@
// Type definitions for p2.js v0.6.0
// Project: https://github.com/schteppe/p2.js/
declare module p2 {
export class AABB {
constructor(options?: {
upperBound?: number[];
lowerBound?: number[];
});
setFromPoints(points: number[][], position: number[], angle: number, skinSize: number): void;
copy(aabb: AABB): void;
extend(aabb: AABB): void;
overlaps(aabb: AABB): boolean;
}
export class Broadphase {
static AABB: number;
static BOUNDING_CIRCLE: number;
static NAIVE: number;
static SAP: number;
static boundingRadiusCheck(bodyA: Body, bodyB: Body): boolean;
static aabbCheck(bodyA: Body, bodyB: Body): boolean;
static canCollide(bodyA: Body, bodyB: Body): boolean;
constructor(type: number);
type: number;
result: Body[];
world: World;
boundingVolumeType: number;
setWorld(world: World): void;
getCollisionPairs(world: World): Body[];
boundingVolumeCheck(bodyA: Body, bodyB: Body): boolean;
}
export class GridBroadphase extends Broadphase {
constructor(options?: {
xmin?: number;
xmax?: number;
ymin?: number;
ymax?: number;
nx?: number;
ny?: number;
});
xmin: number;
xmax: number;
ymin: number;
ymax: number;
nx: number;
ny: number;
binsizeX: number;
binsizeY: number;
}
export class NativeBroadphase extends Broadphase {
}
export class Narrowphase {
contactEquations: ContactEquation[];
frictionEquations: FrictionEquation[];
enableFriction: boolean;
slipForce: number;
frictionCoefficient: number;
surfaceVelocity: number;
reuseObjects: boolean;
resuableContactEquations: any[];
reusableFrictionEquations: any[];
restitution: number;
stiffness: number;
relaxation: number;
frictionStiffness: number;
frictionRelaxation: number;
enableFrictionReduction: boolean;
contactSkinSize: number;
collidedLastStep(bodyA: Body, bodyB: Body): boolean;
reset(): void;
createContactEquation(bodyA: Body, bodyB: Body, shapeA: Shape, shapeB: Shape): ContactEquation;
createFrictionFromContact(c: ContactEquation): FrictionEquation;
}
export class SAPBroadphase extends Broadphase {
axisList: Body[];
axisIndex: number;
}
export class Constraint {
static DISTANCE: number;
static GEAR: number;
static LOCK: number;
static PRISMATIC: number;
static REVOLUTE: number;
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
});
type: number;
equeations: Equation[];
bodyA: Body;
bodyB: Body;
collideConnected: boolean;
update(): void;
setStiffness(stiffness: number): void;
setRelaxation(relaxation: number): void;
}
export class DistanceConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
distance?: number;
localAnchorA?: number[];
localAnchorB?: number[];
maxForce?: number;
});
localAnchorA: number[];
localAnchorB: number[];
distance: number;
maxForce: number;
upperLimitEnabled: boolean;
upperLimit: number;
lowerLimitEnabled: boolean;
lowerLimit: number;
position: number;
setMaxForce(f: number): void;
getMaxForce(): number;
}
export class GearConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
angle?: number;
ratio?: number;
maxTorque?: number;
});
ratio: number;
angle: number;
setMaxTorque(torque: number): void;
getMaxTorque(): number;
}
export class LockConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
localOffsetB?: number[];
localAngleB?: number;
maxForce?: number;
});
setMaxForce(force: number): void;
getMaxForce(): number;
}
export class PrismaticConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
maxForce?: number;
localAnchorA?: number[];
localAnchorB?: number[];
localAxisA?: number[];
disableRotationalLock?: boolean;
upperLimit?: number;
lowerLimit?: number;
});
localAnchorA: number[];
localAnchorB: number[];
localAxisA: number[];
position: number;
velocity: number;
lowerLimitEnabled: boolean;
upperLimitEnabled: boolean;
lowerLimit: number;
upperLimit: number;
upperLimitEquation: ContactEquation;
lowerLimitEquation: ContactEquation;
motorEquation: Equation;
motorEnabled: boolean;
motorSpeed: number;
enableMotor(): void;
disableMotor(): void;
setLimits(lower: number, upper: number): void;
}
export class RevoluteConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
wakeUpBodies?: boolean;
worldPivot?: number[];
localPivotA?: number[];
localPivotB?: number[];
maxForce?: number;
});
pivotA: number[];
pivotB: number[];
motorEquation: RotationalVelocityEquation;
motorEnabled: boolean;
angle: number;
lowerLimitEnabled: boolean;
upperLimitEnabled: boolean;
lowerLimit: number;
upperLimit: number;
upperLimitEquation: ContactEquation;
lowerLimitEquation: ContactEquation;
enableMotor(): void;
disableMotor(): void;
motorIsEnabled(): boolean;
setLimits(lower: number, upper: number): void;
setMotorSpeed(speed: number): void;
getMotorSpeed(): number;
}
export class AngleLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
ratio?: number;
});
computeGq(): number;
setRatio(ratio: number): number;
setMaxTorque(torque: number): number;
}
export class ContactEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
contactPointA: number[];
penetrationVec: number[];
contactPointB: number[];
normalA: number[];
restitution: number;
firstImpact: boolean;
shapeA: Shape;
shapeB: Shape;
computeB(a: number, b: number, h: number): number;
}
export class Equation {
static DEFAULT_STIFFNESS: number;
static DEFAULT_RELAXATION: number;
constructor(bodyA: Body, bodyB: Body, minForce?: number, maxForce?: number);
minForce: number;
maxForce: number;
bodyA: Body;
bodyB: Body;
stiffness: number;
relaxation: number;
G: number[];
offset: number;
a: number;
b: number;
epsilon: number;
timeStep: number;
needsUpdate: boolean;
multiplier: number;
relativeVelocity: number;
enabled: boolean;
gmult(G: number[], vi: number[], wi: number[], vj: number[], wj: number[]): number;
computeB(a: number, b: number, h: number): number;
computeGq(): number;
computeGW(): number;
computeGWlambda(): number;
computeGiMf(): number;
computeGiMGt(): number;
addToWlambda(deltalambda: number): number;
computeInvC(eps: number): number;
}
export class FrictionEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, slipForce: number);
contactPointA: number[];
contactPointB: number[];
t: number[];
shapeA: Shape;
shapeB: Shape;
frictionCoefficient: number;
setSlipForce(slipForce: number): number;
getSlipForce(): number;
computeB(a: number, b: number, h: number): number;
}
export class RotationalLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
});
angle: number;
computeGq(): number;
}
export class RotationalVelocityEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
computeB(a: number, b: number, h: number): number;
}
export class EventEmitter {
on(type: string, listener: Function, context: any): EventEmitter;
has(type: string, listener: Function): boolean;
off(type: string, listener: Function): EventEmitter;
emit(event: any): EventEmitter;
}
export class ContactMaterialOptions {
friction: number;
restitution: number;
stiffness: number;
relaxation: number;
frictionStiffness: number;
frictionRelaxation: number;
surfaceVelocity: number;
}
export class ContactMaterial {
static idCounter: number;
constructor(materialA: Material, materialB: Material, options?: ContactMaterialOptions);
id: number;
materialA: Material;
materialB: Material;
friction: number;
restitution: number;
stiffness: number;
relaxation: number;
frictionStuffness: number;
frictionRelaxation: number;
surfaceVelocity: number;
contactSkinSize: number;
}
export class Material {
static idCounter: number;
constructor(id: number);
id: number;
}
export class vec2 {
static crossLength(a: number[], b: number[]): number;
static crossVZ(out: number[], vec: number[], zcomp: number): number;
static crossZV(out: number[], zcomp: number, vec: number[]): number;
static rotate(out: number[], a: number[], angle: number): void;
static rotate90cw(out: number[], a: number[]): number;
static centroid(out: number[], a: number[], b: number[], c: number[]): number[];
static create(): number[];
static clone(a: number[]): number[];
static fromValues(x: number, y: number): number[];
static copy(out: number[], a: number[]): number[];
static set(out: number[], x: number, y: number): number[];
static toLocalFrame(out: number[], worldPoint: number[], framePosition: number[], frameAngle: number): void;
static toGlobalFrame(out: number[], localPoint: number[], framePosition: number[], frameAngle: number): void;
static add(out: number[], a: number[], b: number[]): number[];
static subtract(out: number[], a: number[], b: number[]): number[];
static sub(out: number[], a: number[], b: number[]): number[];
static multiply(out: number[], a: number[], b: number[]): number[];
static mul(out: number[], a: number[], b: number[]): number[];
static divide(out: number[], a: number[], b: number[]): number[];
static div(out: number[], a: number[], b: number[]): number[];
static scale(out: number[], a: number[], b: number): number[];
static distance(a: number[], b: number[]): number;
static dist(a: number[], b: number[]): number;
static squaredDistance(a: number[], b: number[]): number;
static sqrDist(a: number[], b: number[]): number;
static length(a: number[]): number;
static len(a: number[]): number;
static squaredLength(a: number[]): number;
static sqrLen(a: number[]): number;
static negate(out: number[], a: number[]): number[];
static normalize(out: number[], a: number[]): number[];
static dot(a: number[], b: number[]): number;
static str(a: number[]): string;
}
export class BodyOptions {
mass: number;
position: number[];
velocity: number[];
angle: number;
angularVelocity: number;
force: number[];
angularForce: number;
fixedRotation: number;
}
export class Body extends EventEmitter {
sleepyEvent: {
type: string;
};
sleepEvent: {
type: string;
};
wakeUpEvent: {
type: string;
};
static DYNAMIC: number;
static STATIC: number;
static KINEMATIC: number;
static AWAKE: number;
static SLEEPY: number;
static SLEEPING: number;
constructor(options?: BodyOptions);
id: number;
world: World;
shapes: Shape[];
shapeOffsets: number[][];
shapeAngles: number[];
mass: number;
invMass: number;
inertia: number;
invInertia: number;
invMassSolve: number;
invInertiaSolve: number;
fixedRotation: number;
position: number[];
interpolatedPosition: number[];
interpolatedAngle: number;
previousPosition: number[];
previousAngle: number;
velocity: number[];
vlambda: number[];
wlambda: number[];
angle: number;
angularVelocity: number;
force: number[];
angularForce: number;
damping: number;
angularDamping: number;
type: number;
boundingRadius: number;
aabb: AABB;
aabbNeedsUpdate: boolean;
allowSleep: boolean;
wantsToSleep: boolean;
sleepState: number;
sleepSpeedLimit: number;
sleepTimeLimit: number;
gravityScale: number;
updateSolveMassProperties(): void;
setDensity(density: number): void;
getArea(): number;
getAABB(): AABB;
updateAABB(): void;
updateBoundingRadius(): void;
addShape(shape: Shape, offset?: number[], angle?: number): void;
removeShape(shape: Shape): boolean;
updateMassProperties(): void;
applyForce(force: number[], worldPoint: number[]): void;
toLocalFrame(out: number[], worldPoint: number[]): void;
toWorldFrame(out: number[], localPoint: number[]): void;
fromPolygon(path: number[][], options?: {
optimalDecomp?: boolean;
skipSimpleCheck?: boolean;
removeCollinearPoints?: any; //boolean | number
}): boolean;
adjustCenterOfMass(): void;
setZeroForce(): void;
resetConstraintVelocity(): void;
applyDamping(dy: number): void;
wakeUp(): void;
sleep(): void;
sleepTick(time: number, dontSleep: boolean, dt: number): void;
getVelocityFromPosition(story: number[], dt: number): number[];
getAngularVelocityFromPosition(timeStep: number): number;
overlaps(body: Body): boolean;
}
export class Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
stiffness?: number;
damping?: number;
localAnchorA?: number[];
localAnchorB?: number[];
worldAnchorA?: number[];
worldAnchorB?: number[];
});
stiffness: number;
damping: number;
bodyA: Body;
bodyB: Body;
applyForce(): void;
}
export class LinearSpring extends Spring {
localAnchorA: number[];
localAnchorB: number[];
restLength: number;
setWorldAnchorA(worldAnchorA: number[]): void;
setWorldAnchorB(worldAnchorB: number[]): void;
getWorldAnchorA(result: number[]): number[];
getWorldAnchorB(result: number[]): number[];
applyForce(): void;
}
export class RotationalSpring extends Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
restAngle?: number;
stiffness?: number;
damping?: number;
});
restAngle: number;
}
export class Capsule extends Shape {
constructor(length?: number, radius?: number);
length: number;
radius: number;
}
export class Circle extends Shape {
constructor(radius: number);
radius: number;
}
export class Convex extends Shape {
static triangleArea(a: number[], b: number[], c: number[]): number;
constructor(vertices: number[][], axes: number[]);
vertices: number[][];
axes: number[];
centerOfMass: number[];
triangles: number[];
boundingRadius: number;
projectOntoLocalAxis(localAxis: number[], result: number[]): void;
projectOntoWorldAxis(localAxis: number[], shapeOffset: number[], shapeAngle: number, result: number[]): void;
updateCenterOfMass(): void;
}
export class Heightfield extends Shape {
constructor(data: number[], options?: {
minValue?: number;
maxValue?: number;
elementWidth: number;
});
data: number[];
maxValue: number;
minValue: number;
elementWidth: number;
}
export class Shape {
static idCounter: number;
static CIRCLE: number;
static PARTICLE: number;
static PLANE: number;
static CONVEX: number;
static LINE: number;
static RECTANGLE: number;
static CAPSULE: number;
static HEIGHTFIELD: number;
constructor(type: number);
type: number;
id: number;
boundingRadius: number;
collisionGroup: number;
collisionMask: number;
material: Material;
area: number;
sensor: boolean;
computeMomentOfInertia(mass: number): number;
updateBoundingRadius(): number;
updateArea(): void;
computeAABB(out: AABB, position: number[], angle: number): void;
}
export class Line extends Shape {
constructor(length?: number);
length: number;
}
export class Particle extends Shape {
}
export class Plane extends Shape {
}
export class Rectangle extends Shape {
static sameDimensions(a: Rectangle, b: Rectangle): boolean;
constructor(width?: number, height?: number);
width: number;
height: number;
}
export class Solver extends EventEmitter {
static GS: number;
static ISLAND: number;
constructor(options?: {}, type?: number);
type: number;
equations: Equation[];
equationSortFunction: Equation; //Equation | boolean
solve(dy: number, world: World): void;
solveIsland(dy: number, island: Island): void;
sortEquations(): void;
addEquation(eq: Equation): void;
addEquations(eqs: Equation[]): void;
removeEquation(eq: Equation): void;
removeAllEquations(): void;
}
export class GSSolver extends Solver {
constructor(options?: {
iterations?: number;
tolerance?: number;
});
iterations: number;
tolerance: number;
useZeroRHS: boolean;
frictionIterations: number;
usedIterations: number;
solve(h: number, world: World): void;
}
export class OverlapKeeper {
constructor(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape);
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
tick(): void;
setOverlapping(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Body): void;
bodiesAreOverlapping(bodyA: Body, bodyB: Body): boolean;
set(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape): void;
}
export class TupleDictionary {
data: number[];
keys: number[];
getKey(id1: number, id2: number): string;
getByKey(key: number): number;
get(i: number, j: number): number;
set(i: number, j: number, value: number): number;
reset(): void;
copy(dict: TupleDictionary): void;
}
export class Utils {
static appendArray<T>(a: Array<T>, b: Array<T>): Array<T>;
static chanceRoll(chance: number): boolean;
static defaults(options: any, defaults: any): any;
static extend(a: any, b: any): void;
static randomChoice(choice1: any, choice2: any): any;
static rotateArray(matrix: any[], direction: any): any[];
static splice<T>(array: Array<T>, index: number, howMany: number): void;
static shuffle<T>(array: T[]): T[];
static transposeArray<T>(array: T[]): T[];
}
export class Island {
equations: Equation[];
bodies: Body[];
reset(): void;
getBodies(result: any): Body[];
wantsToSleep(): boolean;
sleep(): boolean;
}
export class IslandManager extends Solver {
static getUnvisitedNode(nodes: Node[]): IslandNode; // IslandNode | boolean
equations: Equation[];
islands: Island[];
nodes: IslandNode[];
visit(node: IslandNode, bds: Body[], eqs: Equation[]): void;
bfs(root: IslandNode, bds: Body[], eqs: Equation[]): void;
split(world: World): Island[];
}
export class IslandNode {
constructor(body: Body);
body: Body;
neighbors: IslandNode[];
equations: Equation[];
visited: boolean;
reset(): void;
}
export class World extends EventEmitter {
postStepEvent: {
type: string;
};
addBodyEvent: {
type: string;
};
removeBodyEvent: {
type: string;
};
addSpringEvent: {
type: string;
};
impactEvent: {
type: string;
bodyA: Body;
bodyB: Body;
shapeA: Shape;
shapeB: Shape;
contactEquation: ContactEquation;
};
postBroadphaseEvent: {
type: string;
pairs: Body[];
};
beginContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
contactEquations: ContactEquation[];
};
endContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
};
preSolveEvent: {
type: string;
contactEquations: ContactEquation[];
frictionEquations: FrictionEquation[];
};
static NO_SLEEPING: number;
static BODY_SLEEPING: number;
static ISLAND_SLEEPING: number;
static integrateBody(body: Body, dy: number): void;
constructor(options?: {
solver?: Solver;
gravity?: number[];
broadphase?: Broadphase;
islandSplit?: boolean;
doProfiling?: boolean;
});
springs: Spring[];
bodies: Body[];
solver: Solver;
narrowphase: Narrowphase;
islandManager: IslandManager;
gravity: number[];
frictionGravity: number;
useWorldGravityAsFrictionGravity: boolean;
useFrictionGravityOnZeroGravity: boolean;
doProfiling: boolean;
lastStepTime: number;
broadphase: Broadphase;
constraints: Constraint[];
defaultMaterial: Material;
defaultContactMaterial: ContactMaterial;
lastTimeStep: number;
applySpringForces: boolean;
applyDamping: boolean;
applyGravity: boolean;
solveConstraints: boolean;
contactMaterials: ContactMaterial[];
time: number;
stepping: boolean;
islandSplit: boolean;
emitImpactEvent: boolean;
sleepMode: number;
addConstraint(c: Constraint): void;
addContactMaterial(contactMaterial: ContactMaterial): void;
removeContactMaterial(cm: ContactMaterial): void;
getContactMaterial(materialA: Material, materialB: Material): ContactMaterial; // ContactMaterial | boolean
removeConstraint(c: Constraint): void;
step(dy: number, timeSinceLastCalled?: number, maxSubSteps?: number): void;
runNarrowphase(np: Narrowphase, bi: Body, si: Shape, xi: any[], ai: number, bj: Body, sj: Shape, xj: any[], aj: number, cm: number, glen: number): void;
addSpring(s: Spring): void;
removeSpring(s: Spring): void;
addBody(body: Body): void;
removeBody(body: Body): void;
getBodyByID(id: number): Body; //Body | boolean
disableBodyCollision(bodyA: Body, bodyB: Body): void;
enableBodyCollision(bodyA: Body, bodyB: Body): void;
clear(): void;
clone(): World;
hitTest(worldPoint: number[], bodies: Body[], precision: number): Body[];
setGlobalEquationParameters(parameters: {
relaxation?: number;
stiffness?: number;
}): void;
setGlobalStiffness(stiffness: number): void;
setGlobalRelaxation(relaxation: number): void;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,3 @@
/// <reference path="../../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.AI.Specs {
"use strict";

View File

@ -1,4 +1,3 @@
/// <reference path="../../../definitions/jasmine.d.ts"/>
/// <reference path="../EnergyDepleter.ts"/>
module SpaceTac.Game.Specs {

View File

@ -1,4 +1,3 @@
/// <reference path="../../../definitions/jasmine.d.ts"/>
/// <reference path="../SubMunitionMissile.ts"/>
module SpaceTac.Game.Specs {

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="../events/BaseLogEvent.ts"/>
module SpaceTac.Game {
@ -6,7 +5,7 @@ module SpaceTac.Game {
// Check a single game log event
function checkEvent(got: BaseLogEvent, ship: Ship, code: string,
target_ship: Ship = null, target_x: number = null, target_y: number = null): void {
target_ship: Ship = null, target_x: number = null, target_y: number = null): void {
if (target_ship) {
if (target_x === null) {
target_x = target_ship.arena_x;

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="../Serializable.ts"/>
module SpaceTac.Game.Specs {

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";
@ -9,7 +7,7 @@ module SpaceTac.Game.Specs {
constructor() {
this.a = "test";
this.b = {c: 5.1, d: ["unit", "test", 5]};
this.b = { c: 5.1, d: ["unit", "test", 5] };
}
get(): string {
@ -31,8 +29,8 @@ module SpaceTac.Game.Specs {
it("merges objects", () => {
expect(Tools.merge({}, {})).toEqual({});
expect(Tools.merge({"a": 1}, {"b": 2})).toEqual({"a": 1, "b": 2});
expect(Tools.merge({"a": 1}, {"a": 3, "b": 2})).toEqual({"a": 3, "b": 2});
expect(Tools.merge({ "a": 1 }, { "b": 2 })).toEqual({ "a": 1, "b": 2 });
expect(Tools.merge({ "a": 1 }, { "a": 3, "b": 2 })).toEqual({ "a": 3, "b": 2 });
});
});
}

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.Game.Specs {
"use strict";

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="TestGame.ts"/>
module SpaceTac.View.Specs {

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="TestGame.ts"/>
/// <reference path="../battle/BattleView.ts"/>

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="TestGame.ts"/>
module SpaceTac.View.Specs {

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.View.Specs {
"use strict";

View File

@ -1,4 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
/// <reference path="../battle/BattleView.ts"/>
module SpaceTac.View.Specs {
@ -6,7 +5,7 @@ module SpaceTac.View.Specs {
// Test game wrapper (use instead of jasmine 'it')
export function ingame_it(desc: string, func: (game: Phaser.Game, state: Phaser.State) => void,
state: Phaser.State = null, ...stateargs: any[]) {
state: Phaser.State = null, ...stateargs: any[]) {
it(desc, (done: () => void) => {
spyOn(console, "log").and.stub();
spyOn(console, "warn").and.stub();

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.View.Specs {
"use strict";

View File

@ -1,5 +1,3 @@
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.View.Specs {
"use strict";

8
typings.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "succession",
"dependencies": {},
"globalDependencies": {
"jasmine": "registry:dt/jasmine#2.5.0+20161003201800",
"phaser": "github:photonstorm/phaser/v2/typescript/typings.json"
}
}