Préparation pour retravailler les armes afin de gérer les attaques dans la nouvelle fenêtre de jets
		
			
				
	
	
		
			65 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { RdDBaseActorSheet } from "../actor/base-actor-sheet.js";
 | 
						|
import { ITEM_TYPES } from "../constants.js";
 | 
						|
import { RdDSheetUtility } from "../rdd-sheet-utility.js";
 | 
						|
import { RdDUtility } from "../rdd-utility.js";
 | 
						|
import { RdDInventaireItemSheet } from "./sheet-base-inventaire.js";
 | 
						|
 | 
						|
export class RdDConteneurItemSheet extends RdDInventaireItemSheet {
 | 
						|
 | 
						|
  static get ITEM_TYPE() { return ITEM_TYPES.conteneur };
 | 
						|
 | 
						|
  async getData() {
 | 
						|
    const formData = await super.getData();
 | 
						|
    if (this.actor) {
 | 
						|
      this.prepareConteneurData(formData);
 | 
						|
    }
 | 
						|
    return formData;
 | 
						|
  }
 | 
						|
 | 
						|
  activateListeners(html) {
 | 
						|
    super.activateListeners(html);
 | 
						|
 | 
						|
    if (!this.options.editable) return;
 | 
						|
 | 
						|
    this.html.find('.conteneur-name a').click(async event => {
 | 
						|
      RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
 | 
						|
      this.render(true);
 | 
						|
    });
 | 
						|
  }
 | 
						|
 | 
						|
  /* -------------------------------------------- */
 | 
						|
  prepareConteneurData(formData) {
 | 
						|
    RdDUtility.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
 | 
						|
    this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires);
 | 
						|
    const subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems;
 | 
						|
    formData.subItems = subItems
 | 
						|
  }
 | 
						|
 | 
						|
  async _onDragStart(event) {
 | 
						|
    console.log("_onDragStart", event);
 | 
						|
    if (event.target.classList.contains("entity-link")) return;
 | 
						|
 | 
						|
    const itemId = event.srcElement?.attributes["data-item-id"].value;
 | 
						|
    const item = this.actor.items.get(itemId);
 | 
						|
    // Create drag data
 | 
						|
    const dragData = {
 | 
						|
      actorId: this.actor.id,
 | 
						|
      type: "Item",
 | 
						|
      data: item.system,
 | 
						|
      uuid: item.uuid
 | 
						|
    };
 | 
						|
 | 
						|
    event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
 | 
						|
  }
 | 
						|
 | 
						|
  async _onDropItem(event, dragData) {
 | 
						|
    if (this.actor) {
 | 
						|
      const destItemId = this.html.find(event.target)?.closest('.item').attr('data-item-id') ?? this.item.id
 | 
						|
      const dropParams = await RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur);
 | 
						|
      await this.actor.processDropItem(dropParams);
 | 
						|
      await this.render(true);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
}
 |