2
0

pcs_has_attr.ts 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. setup.Overwrite.funcRegister("pcs_has_attr",((args)=>{
  2. const functionName:string = args[0];
  3. switch (functionName.toLowerCase()){
  4. case 'and':
  5. if(args.length == 1)
  6. return 0;
  7. for(const bodyTrait of args.slice(1)){
  8. if(setup.qsp_func("pcs_has_attr", bodyTrait) == 0)
  9. return 0;
  10. }
  11. return 1;
  12. case 'or':
  13. if(args.length == 1)
  14. return 0;
  15. for(const bodyTrait of args.slice(1)){
  16. if(setup.qsp_func("pcs_has_attr", bodyTrait) == 1)
  17. return 1;
  18. }
  19. return 0;
  20. case 'nand':
  21. if(args.length == 1)
  22. return 0;
  23. return 1 - (setup.qsp_func("pcs_has_attr", "and", ...(args.slice(1))) as number);
  24. case 'nor':
  25. if(args.length == 1)
  26. return 0;
  27. return 1 - (setup.qsp_func("pcs_has_attr", "or", ...(args.slice(1))) as number);
  28. default:
  29. return undefined;
  30. }
  31. }));