Skip to content

Commit

Permalink
chore(SAI): add missing event param5 (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi authored and Helias committed Dec 25, 2019
1 parent f306506 commit 3cc9920
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ export const SAI_EVENT_PARAM1_NAMES: string[] = [];
export const SAI_EVENT_PARAM2_NAMES: string[] = [];
export const SAI_EVENT_PARAM3_NAMES: string[] = [];
export const SAI_EVENT_PARAM4_NAMES: string[] = [];
export const SAI_EVENT_PARAM5_NAMES: string[] = [];
export const SAI_EVENT_PARAM1_TOOLTIPS: string[] = [];
export const SAI_EVENT_PARAM2_TOOLTIPS: string[] = [];
export const SAI_EVENT_PARAM3_TOOLTIPS: string[] = [];
export const SAI_EVENT_PARAM4_TOOLTIPS: string[] = [];
export const SAI_EVENT_PARAM5_TOOLTIPS: string[] = [];

// SMART_EVENT_UPDATE_IC
SAI_EVENT_TOOLTIPS[SAI_EVENTS.UPDATE_IC] = 'While in combat. Parameters represent a timer: 1000,2000,4000,4000 will call this event_type randomly between 1 and 2 seconds and repeat this every 4 seconds';
Expand Down Expand Up @@ -180,7 +182,9 @@ SAI_EVENT_PARAM1_NAMES[SAI_EVENTS.OOC_LOS] = 'NoHostile';
SAI_EVENT_PARAM2_NAMES[SAI_EVENTS.OOC_LOS] = 'MaxRange';
SAI_EVENT_PARAM3_NAMES[SAI_EVENTS.OOC_LOS] = 'CooldownMin';
SAI_EVENT_PARAM4_NAMES[SAI_EVENTS.OOC_LOS] = 'CooldownMax';
SAI_EVENT_PARAM5_NAMES[SAI_EVENTS.OOC_LOS] = 'PlayerOnly';
SAI_EVENT_PARAM1_TOOLTIPS[SAI_EVENTS.OOC_LOS] = 'If 0, only non-hostile units can trigger this event. If 1, only hostile units can trigger this event';
SAI_EVENT_PARAM5_TOOLTIPS[SAI_EVENTS.OOC_LOS] = '0 or 1';

// SMART_EVENT_RESPAWN
SAI_EVENT_TOOLTIPS[SAI_EVENTS.RESPAWN] = 'On Creature/Gameobject Respawn';
Expand Down Expand Up @@ -284,7 +288,9 @@ SAI_EVENT_PARAM1_NAMES[SAI_EVENTS.IC_LOS] = 'NoHostile';
SAI_EVENT_PARAM2_NAMES[SAI_EVENTS.IC_LOS] = 'MaxDistance';
SAI_EVENT_PARAM3_NAMES[SAI_EVENTS.IC_LOS] = 'CooldownMin';
SAI_EVENT_PARAM4_NAMES[SAI_EVENTS.IC_LOS] = 'CooldownMax';
SAI_EVENT_PARAM5_NAMES[SAI_EVENTS.IC_LOS] = 'PlayerOnly';
SAI_EVENT_PARAM1_TOOLTIPS[SAI_EVENTS.IC_LOS] = 'If 0, only allow non-hostile units to trigger this event. If 1, only allow hostile units to trigger this event.';
SAI_EVENT_PARAM5_TOOLTIPS[SAI_EVENTS.IC_LOS] = '0 or 1';

// SMART_EVENT_PASSENGER_BOARDED
SAI_EVENT_TOOLTIPS[SAI_EVENTS.PASSENGER_BOARDED] = 'When a passenger is boarded';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@
</div>
</div>

<div class="form-row">
<div class="form-group col-7">
<label class="control-label">
{{ getName('param5', EVENT_PARAM5_NAMES[selectedEvent]) }} <i
class="fas fa-info-circle ml-1" [placement]="'auto'"
[hidden]="!EVENT_PARAM5_TOOLTIPS[selectedEvent]"
[tooltip]="EVENT_PARAM5_TOOLTIPS[selectedEvent]"
></i>
</label>
</div>

<div class="form-group col-5">
<input [formControlName]="'event_param5'" id="event_param5" type="number" class="form-control form-control-sm">
</div>
</div>

</div>

<div class="col-sm-6 col-lg-3 sai-category">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SAI_EVENT_PARAM1_TOOLTIPS, SAI_EVENT_PARAM2_NAMES,
SAI_EVENT_PARAM2_TOOLTIPS, SAI_EVENT_PARAM3_NAMES,
SAI_EVENT_PARAM3_TOOLTIPS, SAI_EVENT_PARAM4_NAMES,
SAI_EVENT_PARAM4_TOOLTIPS,
SAI_EVENT_PARAM4_TOOLTIPS, SAI_EVENT_PARAM5_NAMES, SAI_EVENT_PARAM5_TOOLTIPS,
SAI_EVENT_TOOLTIPS, SAI_EVENTS, SAI_EVENTS_KEYS
} from './constants/sai-event';
import {
Expand Down Expand Up @@ -56,6 +56,7 @@ export class SaiEditorComponent extends MultiRowEditorComponent<SmartScripts> {
public readonly EVENT_PARAM2_NAMES = SAI_EVENT_PARAM2_NAMES;
public readonly EVENT_PARAM3_NAMES = SAI_EVENT_PARAM3_NAMES;
public readonly EVENT_PARAM4_NAMES = SAI_EVENT_PARAM4_NAMES;
public readonly EVENT_PARAM5_NAMES = SAI_EVENT_PARAM5_NAMES;
public readonly ACTION_PARAM1_NAMES = SAI_ACTION_PARAM1_NAMES;
public readonly ACTION_PARAM2_NAMES = SAI_ACTION_PARAM2_NAMES;
public readonly ACTION_PARAM3_NAMES = SAI_ACTION_PARAM3_NAMES;
Expand All @@ -70,6 +71,7 @@ export class SaiEditorComponent extends MultiRowEditorComponent<SmartScripts> {
public readonly EVENT_PARAM2_TOOLTIPS = SAI_EVENT_PARAM2_TOOLTIPS;
public readonly EVENT_PARAM3_TOOLTIPS = SAI_EVENT_PARAM3_TOOLTIPS;
public readonly EVENT_PARAM4_TOOLTIPS = SAI_EVENT_PARAM4_TOOLTIPS;
public readonly EVENT_PARAM5_TOOLTIPS = SAI_EVENT_PARAM5_TOOLTIPS;
public readonly ACTION_PARAM1_TOOLTIPS = SAI_ACTION_PARAM1_TOOLTIPS;
public readonly ACTION_PARAM2_TOOLTIPS = SAI_ACTION_PARAM2_TOOLTIPS;
public readonly ACTION_PARAM3_TOOLTIPS = SAI_ACTION_PARAM3_TOOLTIPS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Spy = jasmine.Spy;
import { SaiTopBarComponent } from './sai-top-bar.component';
import { SaiHandlerService } from '../../../../../services/handlers/sai-handler.service';
import { PageObject } from '../../../../../test-utils/page-object';
import { SAI_SEARCH_TYPES } from '../../../../../types/smart-scripts.type';
import { SAI_TYPES } from '../../../../../types/smart-scripts.type';
import { QueryService } from '../../../../../services/query.service';
import { Component, ViewChild } from '@angular/core';

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('SaiTopBarComponent', () => {

beforeEach(() => {
handler = TestBed.get(SaiHandlerService);
handler['_selected'] = JSON.stringify({ source_type: SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT, entryorguid });
handler['_selected'] = JSON.stringify({ source_type: SAI_TYPES.SAI_TYPE_GAMEOBJECT, entryorguid });
querySpy = spyOn(TestBed.get(QueryService), 'query');

fixture = TestBed.createComponent(TestHostComponent);
Expand All @@ -65,12 +65,12 @@ describe('SaiTopBarComponent', () => {
});

for (const { testId, type, positive, expected } of [
{ testId: 1, type: SAI_SEARCH_TYPES.SAI_TYPE_AREATRIGGER, positive: true, expected: `Areatrigger ID ${entryorguid}` },
{ testId: 2, type: SAI_SEARCH_TYPES.SAI_TYPE_TIMED_ACTIONLIST, positive: true, expected: `Timed Actionlist ID ${entryorguid}` },
{ testId: 3, type: SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT, positive: true, expected: `Gameobject ID ${entryorguid}` },
{ testId: 4, type: SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT, positive: false, expected: `Gameobject GUID ${entryorguid}` },
{ testId: 5, type: SAI_SEARCH_TYPES.SAI_TYPE_CREATURE, positive: true, expected: `Creature ID ${entryorguid}` },
{ testId: 6, type: SAI_SEARCH_TYPES.SAI_TYPE_CREATURE, positive: false, expected: `Creature GUID ${entryorguid}` },
{ testId: 1, type: SAI_TYPES.SAI_TYPE_AREATRIGGER, positive: true, expected: `Areatrigger ID ${entryorguid}` },
{ testId: 2, type: SAI_TYPES.SAI_TYPE_TIMED_ACTIONLIST, positive: true, expected: `Timed Actionlist ID ${entryorguid}` },
{ testId: 3, type: SAI_TYPES.SAI_TYPE_GAMEOBJECT, positive: true, expected: `Gameobject ID ${entryorguid}` },
{ testId: 4, type: SAI_TYPES.SAI_TYPE_GAMEOBJECT, positive: false, expected: `Gameobject GUID ${entryorguid}` },
{ testId: 5, type: SAI_TYPES.SAI_TYPE_CREATURE, positive: true, expected: `Creature ID ${entryorguid}` },
{ testId: 6, type: SAI_TYPES.SAI_TYPE_CREATURE, positive: false, expected: `Creature GUID ${entryorguid}` },
]) {
it(`should correctly handle different types [${testId}]`, () => {
querySpy.and.returnValue(of({ results: [{ name }] }));
Expand All @@ -83,7 +83,7 @@ describe('SaiTopBarComponent', () => {

describe('after fetching the creature name', () => {
beforeEach(() => {
handler['_selected'] = JSON.stringify({ source_type: SAI_SEARCH_TYPES.SAI_TYPE_CREATURE, entryorguid });
handler['_selected'] = JSON.stringify({ source_type: SAI_TYPES.SAI_TYPE_CREATURE, entryorguid });
});

it('should correctly show the name', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';

import { SaiHandlerService } from '../../../../../services/handlers/sai-handler.service';
import { SAI_SEARCH_TYPES, SmartScripts } from '../../../../../types/smart-scripts.type';
import { SAI_TYPES, SmartScripts } from '../../../../../types/smart-scripts.type';
import { QueryService } from '../../../../../services/query.service';
import { SubscriptionHandler } from '../../../../../utils/subscription-handler/subscription-handler';

Expand Down Expand Up @@ -30,20 +30,20 @@ export class SaiTopBarComponent extends SubscriptionHandler implements OnInit {

switch (selected.source_type) {

case SAI_SEARCH_TYPES.SAI_TYPE_CREATURE:
case SAI_TYPES.SAI_TYPE_CREATURE:
this._selectedText = `Creature ${this.getGuidOrIdText(selected.entryorguid)}`;
this.appendCreatureName(selected.entryorguid);
break;

case SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT:
case SAI_TYPES.SAI_TYPE_GAMEOBJECT:
this._selectedText = `Gameobject ${this.getGuidOrIdText(selected.entryorguid)}`;
break;

case SAI_SEARCH_TYPES.SAI_TYPE_AREATRIGGER:
case SAI_TYPES.SAI_TYPE_AREATRIGGER:
this._selectedText = `Areatrigger ID ${selected.entryorguid}`;
break;

case SAI_SEARCH_TYPES.SAI_TYPE_TIMED_ACTIONLIST:
case SAI_TYPES.SAI_TYPE_TIMED_ACTIONLIST:
this._selectedText = `Timed Actionlist ID ${selected.entryorguid}`;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, } from '@angular/core';
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';

import { SaiHandlerService } from '../../../../services/handlers/sai-handler.service';
import { SAI_SEARCH_TYPES, SAI_SEARCH_TYPES_KEYS } from '../../../../types/smart-scripts.type';
import { SAI_TYPES, SAI_TYPES_KEYS } from '../../../../types/smart-scripts.type';

@Component({
selector: 'app-sai-search-entity',
Expand All @@ -11,20 +11,20 @@ import { SAI_SEARCH_TYPES, SAI_SEARCH_TYPES_KEYS } from '../../../../types/smart
})
export class SaiSearchEntityComponent {

public readonly SAI_SEARCH_TYPES = SAI_SEARCH_TYPES;
public readonly SAI_SEARCH_TYPES_KEYS = SAI_SEARCH_TYPES_KEYS;
public readonly SAI_SEARCH_TYPES = SAI_TYPES;
public readonly SAI_SEARCH_TYPES_KEYS = SAI_TYPES_KEYS;

public readonly form = new FormGroup({
'source_type': new FormControl(null, [Validators.required]),
'entryorguid': new FormControl(null, [Validators.required]),
});

get typeCreatureSelected(): boolean {
return this.sourceTypeControl.value === SAI_SEARCH_TYPES.SAI_TYPE_CREATURE;
return this.sourceTypeControl.value === SAI_TYPES.SAI_TYPE_CREATURE;
}

get typeGameobjectSelected(): boolean {
return this.sourceTypeControl.value === SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT;
return this.sourceTypeControl.value === SAI_TYPES.SAI_TYPE_GAMEOBJECT;
}

get sourceTypeControl(): AbstractControl {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';

import { SelectComplexKeyComponent } from '../../shared/select-complex-key.component';
import { SAI_SEARCH_TYPES, SAI_SEARCH_TYPES_KEYS, SmartScripts } from '../../../../types/smart-scripts.type';
import { SAI_TYPES, SAI_TYPES_KEYS, SmartScripts } from '../../../../types/smart-scripts.type';
import { SaiHandlerService } from '../../../../services/handlers/sai-handler.service';
import { SaiSearchService } from '../../../../services/search/sai-search.service';

Expand All @@ -12,8 +12,8 @@ import { SaiSearchService } from '../../../../services/search/sai-search.service
})
export class SaiSearchExistingComponent extends SelectComplexKeyComponent<SmartScripts> {

public readonly SAI_SEARCH_TYPES = SAI_SEARCH_TYPES;
public readonly SAI_SEARCH_TYPES_KEYS = SAI_SEARCH_TYPES_KEYS;
public readonly SAI_SEARCH_TYPES = SAI_TYPES;
public readonly SAI_SEARCH_TYPES_KEYS = SAI_TYPES_KEYS;

constructor(
public selectService: SaiSearchService,
Expand Down
12 changes: 6 additions & 6 deletions src/app/services/handlers/sai-handler.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { SaiHandlerService } from './sai-handler.service';
import { QueryService } from '../query.service';
import { of } from 'rxjs';
import { SAI_SEARCH_TYPES } from '../../types/smart-scripts.type';
import { SAI_TYPES } from '../../types/smart-scripts.type';
import { Router } from '@angular/router';

describe('SaiHandlerService', () => {
Expand Down Expand Up @@ -41,28 +41,28 @@ describe('SaiHandlerService', () => {

for (const { sourceType, id, expectedQuery } of [
{
sourceType: SAI_SEARCH_TYPES.SAI_TYPE_CREATURE,
sourceType: SAI_TYPES.SAI_TYPE_CREATURE,
id: entry,
expectedQuery: `UPDATE \`creature_template\` SET \`AIName\` = 'SmartAI' WHERE \`entry\` = ${entry};`,
},
{
sourceType: SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT,
sourceType: SAI_TYPES.SAI_TYPE_GAMEOBJECT,
id: entry,
expectedQuery: `UPDATE \`gameobject_template\` SET \`AIName\` = 'SmartGameObjectAI' WHERE \`entry\` = ${entry};`,
},
{
sourceType: SAI_SEARCH_TYPES.SAI_TYPE_AREATRIGGER,
sourceType: SAI_TYPES.SAI_TYPE_AREATRIGGER,
id: entry,
expectedQuery: `DELETE FROM \`areatrigger_scripts\` WHERE \`entry\` = ${entry};\n` +
`INSERT INTO \`areatrigger_scripts\` (\`entry\`, \`ScriptName\`) VALUES (${entry}, 'SmartTrigger');`,
},
{
sourceType: SAI_SEARCH_TYPES.SAI_TYPE_TIMED_ACTIONLIST,
sourceType: SAI_TYPES.SAI_TYPE_TIMED_ACTIONLIST,
id: entry,
expectedQuery: null,
},
{
sourceType: SAI_SEARCH_TYPES.SAI_TYPE_CREATURE,
sourceType: SAI_TYPES.SAI_TYPE_CREATURE,
id: -entry,
expectedQuery: null,
},
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/handlers/sai-handler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { Router } from '@angular/router';

import { ComplexKeyHandlerService } from './complex-key.handler.service';
import { SAI_ID_FIELDS, SAI_SEARCH_TYPES, SmartScripts } from '../../types/smart-scripts.type';
import { SAI_ID_FIELDS, SAI_TYPES, SmartScripts } from '../../types/smart-scripts.type';
import { QueryService } from '../query.service';

@Injectable({
Expand Down Expand Up @@ -53,13 +53,13 @@ export class SaiHandlerService extends ComplexKeyHandlerService<SmartScripts> {

switch (selected.source_type) {

case SAI_SEARCH_TYPES.SAI_TYPE_CREATURE:
case SAI_TYPES.SAI_TYPE_CREATURE:
return `UPDATE \`creature_template\` SET \`AIName\` = 'SmartAI' WHERE \`entry\` = ${selected.entryorguid};`;

case SAI_SEARCH_TYPES.SAI_TYPE_GAMEOBJECT:
case SAI_TYPES.SAI_TYPE_GAMEOBJECT:
return `UPDATE \`gameobject_template\` SET \`AIName\` = 'SmartGameObjectAI' WHERE \`entry\` = ${selected.entryorguid};`;

case SAI_SEARCH_TYPES.SAI_TYPE_AREATRIGGER:
case SAI_TYPES.SAI_TYPE_AREATRIGGER:
return `DELETE FROM \`areatrigger_scripts\` WHERE \`entry\` = ${selected.entryorguid};\n` +
`INSERT INTO \`areatrigger_scripts\` (\`entry\`, \`ScriptName\`) VALUES (${selected.entryorguid}, 'SmartTrigger');`;

Expand Down
4 changes: 2 additions & 2 deletions src/app/types/smart-scripts.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const SAI_ID_FIELDS = [
export const SAI_ID_2 = 'id';
export const SAI_SEARCH_FIELDS = SAI_ID_FIELDS;

export enum SAI_SEARCH_TYPES {
export enum SAI_TYPES {
SAI_TYPE_CREATURE,
SAI_TYPE_GAMEOBJECT,
SAI_TYPE_AREATRIGGER,
SAI_TYPE_TIMED_ACTIONLIST = 9,
}
export const SAI_SEARCH_TYPES_KEYS = getEnumKeys(SAI_SEARCH_TYPES);
export const SAI_TYPES_KEYS = getEnumKeys(SAI_TYPES);

export class SmartScripts extends TableRow {
entryorguid: number = 0;
Expand Down

0 comments on commit 3cc9920

Please sign in to comment.