No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.ts 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /// <reference path="../dispatcher/dispatcher.ts"/>
  2. module rpgcards {
  3. /* State actions */
  4. export class ActionReset implements Action {
  5. constructor() {}
  6. }
  7. /* Deck actions */
  8. export class ActionNewDeck implements Action {
  9. constructor() {}
  10. }
  11. export class ActionSetDeckName implements Action {
  12. constructor(private _id: string, private _name:string) {}
  13. get id(): string {return this._id}
  14. get name(): string {return this._name}
  15. }
  16. export class ActionSetDeckDescription implements Action {
  17. constructor(private _id: string, private _desc:string) {}
  18. get id(): string {return this._id}
  19. get desc(): string {return this._desc}
  20. }
  21. export class ActionDeleteDeck implements Action {
  22. constructor(private _id: string) {}
  23. get id(): string {return this._id}
  24. }
  25. export class ActionSelectDeck implements Action {
  26. constructor(private _id: string) {}
  27. get id(): string {return this._id}
  28. }
  29. /* Card actions */
  30. export class ActionNewCard implements Action {
  31. constructor(private _deck_id: string) {}
  32. get deck_id(): string {return this._deck_id}
  33. }
  34. export class ActionDeleteCard implements Action {
  35. constructor(private _id: string) {}
  36. get id(): string {return this._id}
  37. }
  38. export class ActionSelectCard implements Action {
  39. constructor(private _id: string) {}
  40. get id(): string {return this._id}
  41. }
  42. export class ActionModifyCard implements Action {
  43. constructor(private _id: string, private _prop: string, private _val: string) {}
  44. get id(): string {return this._id}
  45. get prop(): string {return this._prop}
  46. get val(): string {return this._val}
  47. }
  48. export class Actions {
  49. constructor(private _dispatcher: Dispatcher) {
  50. }
  51. public reset(): void {
  52. this._dispatcher.dispatch(new ActionReset());
  53. }
  54. public newDeck(): void {
  55. this._dispatcher.dispatch(new ActionNewDeck());
  56. }
  57. public setDeckName(id:string, name:string): void {
  58. this._dispatcher.dispatch(new ActionSetDeckName(id, name));
  59. }
  60. public setDeckDesc(id:string, desc:string): void {
  61. this._dispatcher.dispatch(new ActionSetDeckDescription(id, desc));
  62. }
  63. public deleteDeck(id: string): void {
  64. this._dispatcher.dispatch(new ActionDeleteDeck(id));
  65. }
  66. public selectDeck(id: string): void {
  67. this._dispatcher.dispatch(new ActionSelectDeck(id));
  68. }
  69. public newCard(deck_id: string): void {
  70. this._dispatcher.dispatch(new ActionNewCard(deck_id));
  71. }
  72. public deleteCard(id: string): void {
  73. this._dispatcher.dispatch(new ActionDeleteCard(id));
  74. }
  75. public selectCard(id: string): void {
  76. this._dispatcher.dispatch(new ActionSelectCard(id));
  77. }
  78. }
  79. }