<commit_before>/**
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import { Callback } from './GameClientModels/_Updatable';

import { LoadingState } from './GameClientModels/LoadingState';
import { SelfPlayerState } from './GameClientModels/PlayerState';
import { FriendlyTargetState } from './GameClientModels/FriendlyTargetState';
import { EnemyTargetState } from './GameClientModels/EnemyTargetState';
import { Plot } from './GameClientModels/Plot';
import { KeyActions } from './GameClientModels/KeyActions';

/**
 * Export all models
 */
export {
  Callback,
  LoadingState,
  SelfPlayerState,
  FriendlyTargetState,
  EnemyTargetState,
};

/**
 * GameModel interface defines the structure and functionality of the global game object as presented by the game
 * client.
 *
 * If game is not defined, then the page has not yet been initialized by the game engine or we are not running in the
 * context of the game client.
 *
 * In the case that game is not defined, replacement methods are in place to mock Coherent engine support for functions
 * provided through this global api object.
 */

export interface GameModel {

  /**
   * The Patch resource channel identification number.
   */
  patchResourceChannel: number;

  /**
   * The current access token used to identify the user in requests to CSE services.
   */
  accessToken: string;

  /**
   * The host address for the Web Api server the UI should make requests to.
   */
  webAPIHost: string;

  /**
   * The host address for the specific game server that this client is connected to.
   * *Note:* some API requests will be made directly to the game server itself, those use this address.
   */
  serverHost: string;

  /**
   * Identifying number for the server shard this client is currently logged in to.
   */
  shardID: number;

  /**
   * Unique Network Identifier (I think??)
   * TODO: Should we remove this?
   */
  pktHash: string;

  /**
   * Forces the client to reload the entire UI.
   */
  reloadUI: () => void;

  /**
   * Quit the game!
   */
  quit: () => void;

  /**
   * Triggers a client Key action using the id of that KeyBind. Essentially, acts as if the client keybind was pressed.
   * @param {Number} id Matches id in KeyBind for any action
   * @return {Success | Failure}
   */
  triggerKeyAction: (id: Number) => Success | Failure;

  /**
   * Sends a slash command to the game client.
   * @param {String} command the command to send, does not include a preceding slash
   */
  sendSlashCommand: (command: string) => void;

  /**
   * Take a screenshot
   * @return {Screenshot} Image & Path to screenshot
   */
  takeScreenshot: () => Screenshot[];

  /**
   * Player a sound through the game audio engine
   * @param {Number} soundID ID of the sound to play
   */
  playGameSound: (soundID: number) => void;

  /* -------------------------------------------------- */
  /* OPTIONS                                            */
  /* -------------------------------------------------- */

  /**
   * Gets all Keybinds from the client
   */
  getKeybinds: () => Keybind[];

  /**
   * Request that the client listen for a key combination to bind a key value to.
   * @param {Number} id Identifier of the Keybinding to be bound
   * @param {Number} index Index of binds to set / replace with the new binding
   * @returns {Binding} The newly bound key information
   */
  bindKey: (id: number, index: number) => Binding;

  /**
   * Request that the client clear a particular key bind
   * @param {Number} id Identifier of the Keybinding to be cleared
   * @param {Number} index Index of bind to clear
   */
  clearKeybind: (id: number, index: number) => void;

  /**
   * Get all options from the client
   */
  getOptions: () => GameOption[];

  /**
   * Batch set of all passed in options
   * @param {GameOption[]} options The options to set
   * @return Whether or not the options all saved correctly
   */
  setOptions: (options: GameOption[]) => Success | Failure & { failures: [{ option: GameOption, reason: string }] };

  /**
   * Test a single option without saving it, this allows preview of changes without saving them immediately
   * When called, this method should change the setting on the client without saving it to file or the server
   * @param {GameOption} option The option to test
   * @return Whether or not the option was valid to test
   */
  testOption: (option: GameOption) => Success | Failure;

  /**
   * Cancels all option tests and revert to the currently saved options
   */
  cancelTests: () => void;

  /**
   * Restores options to their default values based on category
   * @param {OptionCategory} The category of options to reset
   */
  resetOptions: (category: OptionCategory) => void;

  /* -------------------------------------------------- */
  /* ITEM PLACEMENT API                                 */
  /* -------------------------------------------------- */

  /**
   * Action used to begin deployment of a deployable item
   * @param {Number} itemDefID Item Definition ID of the deployable
   * @param {String} itemInstanceID Instance ID of the deployable item
   * @return {Boolean} whether or not placement actually started in the client.
   */
  startItemPlacement: (itemDefID: number, itemInstanceID: string) => boolean;

  /**
   * Commit active placed item with its current position & orientation
   * *IMPORTANT* This item placement is client-side only! The UI must make a move item request with the returned
   * positional data from this call to actually move the item to position on th e game server.
   * @return
   * {
   *   success: true | false - whether or not the commit was successful
   *   position?: {Vec3f} - where the item was placed
   *   rotation?: {Euler3f} - orientation of the placed item
   *   actionID?: {String} - ID used in creating a move request
   * }
   */
  commitItemPlacement: () => Failure | Success & { position: Vec3f; rotation: Euler3f, actionID: string };

  /**
   * Reset active placed item's position and orientation
   */
  resetItemPlacement: () => void;

  /**
   * Cancel active placed item's placement
   * @return {Boolean} whether or not the placement was cancelled
   */<commit_msg>Update commitItemPLacement return<commit_after>/**
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import { Callback } from './GameClientModels/_Updatable';

import { LoadingState } from './GameClientModels/LoadingState';
import { SelfPlayerState } from './GameClientModels/PlayerState';
import { FriendlyTargetState } from './GameClientModels/FriendlyTargetState';
import { EnemyTargetState } from './GameClientModels/EnemyTargetState';
import { Plot } from './GameClientModels/Plot';
import { KeyActions } from './GameClientModels/KeyActions';

/**
 * Export all models
 */
export {
  Callback,
  LoadingState,
  SelfPlayerState,
  FriendlyTargetState,
  EnemyTargetState,
};

/**
 * GameModel interface defines the structure and functionality of the global game object as presented by the game
 * client.
 *
 * If game is not defined, then the page has not yet been initialized by the game engine or we are not running in the
 * context of the game client.
 *
 * In the case that game is not defined, replacement methods are in place to mock Coherent engine support for functions
 * provided through this global api object.
 */

export interface GameModel {

  /**
   * The Patch resource channel identification number.
   */
  patchResourceChannel: number;

  /**
   * The current access token used to identify the user in requests to CSE services.
   */
  accessToken: string;

  /**
   * The host address for the Web Api server the UI should make requests to.
   */
  webAPIHost: string;

  /**
   * The host address for the specific game server that this client is connected to.
   * *Note:* some API requests will be made directly to the game server itself, those use this address.
   */
  serverHost: string;

  /**
   * Identifying number for the server shard this client is currently logged in to.
   */
  shardID: number;

  /**
   * Unique Network Identifier (I think??)
   * TODO: Should we remove this?
   */
  pktHash: string;

  /**
   * Forces the client to reload the entire UI.
   */
  reloadUI: () => void;

  /**
   * Quit the game!
   */
  quit: () => void;

  /**
   * Triggers a client Key action using the id of that KeyBind. Essentially, acts as if the client keybind was pressed.
   * @param {Number} id Matches id in KeyBind for any action
   * @return {Success | Failure}
   */
  triggerKeyAction: (id: Number) => Success | Failure;

  /**
   * Sends a slash command to the game client.
   * @param {String} command the command to send, does not include a preceding slash
   */
  sendSlashCommand: (command: string) => void;

  /**
   * Take a screenshot
   * @return {Screenshot} Image & Path to screenshot
   */
  takeScreenshot: () => Screenshot[];

  /**
   * Player a sound through the game audio engine
   * @param {Number} soundID ID of the sound to play
   */
  playGameSound: (soundID: number) => void;

  /* -------------------------------------------------- */
  /* OPTIONS                                            */
  /* -------------------------------------------------- */

  /**
   * Gets all Keybinds from the client
   */
  getKeybinds: () => Keybind[];

  /**
   * Request that the client listen for a key combination to bind a key value to.
   * @param {Number} id Identifier of the Keybinding to be bound
   * @param {Number} index Index of binds to set / replace with the new binding
   * @returns {Binding} The newly bound key information
   */
  bindKey: (id: number, index: number) => Binding;

  /**
   * Request that the client clear a particular key bind
   * @param {Number} id Identifier of the Keybinding to be cleared
   * @param {Number} index Index of bind to clear
   */
  clearKeybind: (id: number, index: number) => void;

  /**
   * Get all options from the client
   */
  getOptions: () => GameOption[];

  /**
   * Batch set of all passed in options
   * @param {GameOption[]} options The options to set
   * @return Whether or not the options all saved correctly
   */
  setOptions: (options: GameOption[]) => Success | Failure & { failures: [{ option: GameOption, reason: string }] };

  /**
   * Test a single option without saving it, this allows preview of changes without saving them immediately
   * When called, this method should change the setting on the client without saving it to file or the server
   * @param {GameOption} option The option to test
   * @return Whether or not the option was valid to test
   */
  testOption: (option: GameOption) => Success | Failure;

  /**
   * Cancels all option tests and revert to the currently saved options
   */
  cancelTests: () => void;

  /**
   * Restores options to their default values based on category
   * @param {OptionCategory} The category of options to reset
   */
  resetOptions: (category: OptionCategory) => void;

  /* -------------------------------------------------- */
  /* ITEM PLACEMENT API                                 */
  /* -------------------------------------------------- */

  /**
   * Action used to begin deployment of a deployable item
   * @param {Number} itemDefID Item Definition ID of the deployable
   * @param {String} itemInstanceID Instance ID of the deployable item
   * @return {Boolean} whether or not placement actually started in the client.
   */
  startItemPlacement: (itemDefID: number, itemInstanceID: string) => boolean;

  /**
   * Commit active placed item with its current position & orientation
   * *IMPORTANT* This item placement is client-side only! The UI must make a move item request with the returned
   * positional data from this call to actually move the item to position on th e game server.
   * @return
   * {
   *   success: true | false - whether or not the commit was successful
   *   position?: {Vec3f} - where the item was placed
   *   rotation?: {Euler3f} - orientation of the placed item
   *   actionID?: {String} - ID used in creating a move request
   * }
   */
  commitItemPlacement: () => Failure | Success & {
    placement: {
      itemDefID: number;
      itemInstanceID: string;
      position: Vec3f;
      rotation: Euler3f,
      actionID: string
    },
  };

  /**
   * Reset active placed item's position and orientation
   */
  resetItemPlacement: () => void;

  /**
   * Cancel active placed item's placement
   * @return {Boolean} whether or not the placement was cancelled
   */
{'fraction_non_alphanumeric': 0.12350690920446561, 'fraction_numerical': 0.0012491217112967445, 'mean_word_length': 2.6247877758913414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2626922', 'n_tokens_mistral': 3468, 'n_tokens_neox': 3361, 'n_words': 1487}